Skip to content

Commit

Permalink
Workaround for codesandbox having bug with TS enums (graphql#3686)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored and yaacovCR committed Aug 19, 2024
1 parent 5c7d4d1 commit 9bba83f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/language/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,12 @@ export interface OperationDefinitionNode {
readonly selectionSet: SelectionSetNode;
}

export enum OperationTypeNode {
enum OperationTypeNode {
QUERY = 'query',
MUTATION = 'mutation',
SUBSCRIPTION = 'subscription',
}
export { OperationTypeNode };

export interface VariableDefinitionNode {
readonly kind: Kind.VARIABLE_DEFINITION;
Expand Down
4 changes: 3 additions & 1 deletion src/language/directiveLocation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The set of allowed directive location values.
*/
export enum DirectiveLocation {
enum DirectiveLocation {
/** Request Definitions */
QUERY = 'QUERY',
MUTATION = 'MUTATION',
Expand All @@ -24,3 +24,5 @@ export enum DirectiveLocation {
INPUT_OBJECT = 'INPUT_OBJECT',
INPUT_FIELD_DEFINITION = 'INPUT_FIELD_DEFINITION',
}

export { DirectiveLocation };
4 changes: 3 additions & 1 deletion src/language/kinds.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The set of allowed kind values for AST nodes.
*/
export enum Kind {
enum Kind {
/** Name */
NAME = 'Name',

Expand Down Expand Up @@ -72,3 +72,5 @@ export enum Kind {
ENUM_TYPE_EXTENSION = 'EnumTypeExtension',
INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension',
}

export { Kind };
4 changes: 3 additions & 1 deletion src/language/tokenKind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* An exported enum describing the different kinds of tokens that the
* lexer emits.
*/
export enum TokenKind {
enum TokenKind {
SOF = '<SOF>',
EOF = '<EOF>',
BANG = '!',
Expand All @@ -27,3 +27,5 @@ export enum TokenKind {
BLOCK_STRING = 'BlockString',
COMMENT = 'Comment',
}

export { TokenKind };
3 changes: 2 additions & 1 deletion src/type/introspection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ export const __EnumValue: GraphQLObjectType = new GraphQLObjectType({
} as GraphQLFieldConfigMap<GraphQLEnumValue, unknown>),
});

export enum TypeKind {
enum TypeKind {
SCALAR = 'SCALAR',
OBJECT = 'OBJECT',
INTERFACE = 'INTERFACE',
Expand All @@ -453,6 +453,7 @@ export enum TypeKind {
LIST = 'LIST',
NON_NULL = 'NON_NULL',
}
export { TypeKind };

export const __TypeKind: GraphQLEnumType = new GraphQLEnumType({
name: '__TypeKind',
Expand Down
6 changes: 4 additions & 2 deletions src/utilities/findBreakingChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import type { GraphQLSchema } from '../type/schema.js';
import { astFromValue } from './astFromValue.js';
import { sortValueNode } from './sortValueNode.js';

export enum BreakingChangeType {
enum BreakingChangeType {
TYPE_REMOVED = 'TYPE_REMOVED',
TYPE_CHANGED_KIND = 'TYPE_CHANGED_KIND',
TYPE_REMOVED_FROM_UNION = 'TYPE_REMOVED_FROM_UNION',
Expand All @@ -52,15 +52,17 @@ export enum BreakingChangeType {
DIRECTIVE_REPEATABLE_REMOVED = 'DIRECTIVE_REPEATABLE_REMOVED',
DIRECTIVE_LOCATION_REMOVED = 'DIRECTIVE_LOCATION_REMOVED',
}
export { BreakingChangeType };

export enum DangerousChangeType {
enum DangerousChangeType {
VALUE_ADDED_TO_ENUM = 'VALUE_ADDED_TO_ENUM',
TYPE_ADDED_TO_UNION = 'TYPE_ADDED_TO_UNION',
OPTIONAL_INPUT_FIELD_ADDED = 'OPTIONAL_INPUT_FIELD_ADDED',
OPTIONAL_ARG_ADDED = 'OPTIONAL_ARG_ADDED',
IMPLEMENTED_INTERFACE_ADDED = 'IMPLEMENTED_INTERFACE_ADDED',
ARG_DEFAULT_VALUE_CHANGE = 'ARG_DEFAULT_VALUE_CHANGE',
}
export { DangerousChangeType };

export interface BreakingChange {
type: BreakingChangeType;
Expand Down

0 comments on commit 9bba83f

Please sign in to comment.