From af8221a6504b66a95b9bc0c20935e8f18b23d7d2 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Tue, 16 Aug 2022 21:51:23 +0300 Subject: [PATCH] Workaround for codesandbox having bug with TS enums (#3686) --- src/language/ast.ts | 3 ++- src/language/directiveLocation.ts | 3 ++- src/language/kinds.ts | 3 ++- src/language/tokenKind.ts | 3 ++- src/type/introspection.ts | 3 ++- src/utilities/findBreakingChanges.ts | 6 ++++-- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/language/ast.ts b/src/language/ast.ts index 0b30366df0..29029342a1 100644 --- a/src/language/ast.ts +++ b/src/language/ast.ts @@ -323,11 +323,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; diff --git a/src/language/directiveLocation.ts b/src/language/directiveLocation.ts index e98ddf6d75..5c8aeb7240 100644 --- a/src/language/directiveLocation.ts +++ b/src/language/directiveLocation.ts @@ -1,7 +1,7 @@ /** * The set of allowed directive location values. */ -export enum DirectiveLocation { +enum DirectiveLocation { /** Request Definitions */ QUERY = 'QUERY', MUTATION = 'MUTATION', @@ -24,6 +24,7 @@ export enum DirectiveLocation { INPUT_OBJECT = 'INPUT_OBJECT', INPUT_FIELD_DEFINITION = 'INPUT_FIELD_DEFINITION', } +export { DirectiveLocation }; /** * The enum type representing the directive location values. diff --git a/src/language/kinds.ts b/src/language/kinds.ts index 39b2a8e675..cd05f66a3b 100644 --- a/src/language/kinds.ts +++ b/src/language/kinds.ts @@ -1,7 +1,7 @@ /** * The set of allowed kind values for AST nodes. */ -export enum Kind { +enum Kind { /** Name */ NAME = 'Name', @@ -67,6 +67,7 @@ export enum Kind { ENUM_TYPE_EXTENSION = 'EnumTypeExtension', INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension', } +export { Kind }; /** * The enum type representing the possible kind values of AST nodes. diff --git a/src/language/tokenKind.ts b/src/language/tokenKind.ts index 4878d697b0..0c260df99e 100644 --- a/src/language/tokenKind.ts +++ b/src/language/tokenKind.ts @@ -2,7 +2,7 @@ * An exported enum describing the different kinds of tokens that the * lexer emits. */ -export enum TokenKind { +enum TokenKind { SOF = '', EOF = '', BANG = '!', @@ -26,6 +26,7 @@ export enum TokenKind { BLOCK_STRING = 'BlockString', COMMENT = 'Comment', } +export { TokenKind }; /** * The enum type representing the token kinds values. diff --git a/src/type/introspection.ts b/src/type/introspection.ts index e5fce6f241..f5e4b07ea7 100644 --- a/src/type/introspection.ts +++ b/src/type/introspection.ts @@ -435,7 +435,7 @@ export const __EnumValue: GraphQLObjectType = new GraphQLObjectType({ } as GraphQLFieldConfigMap), }); -export enum TypeKind { +enum TypeKind { SCALAR = 'SCALAR', OBJECT = 'OBJECT', INTERFACE = 'INTERFACE', @@ -445,6 +445,7 @@ export enum TypeKind { LIST = 'LIST', NON_NULL = 'NON_NULL', } +export { TypeKind }; export const __TypeKind: GraphQLEnumType = new GraphQLEnumType({ name: '__TypeKind', diff --git a/src/utilities/findBreakingChanges.ts b/src/utilities/findBreakingChanges.ts index 0bf0d453b4..2489af9d62 100644 --- a/src/utilities/findBreakingChanges.ts +++ b/src/utilities/findBreakingChanges.ts @@ -34,7 +34,7 @@ import type { GraphQLSchema } from '../type/schema'; import { astFromValue } from './astFromValue'; import { sortValueNode } from './sortValueNode'; -export enum BreakingChangeType { +enum BreakingChangeType { TYPE_REMOVED = 'TYPE_REMOVED', TYPE_CHANGED_KIND = 'TYPE_CHANGED_KIND', TYPE_REMOVED_FROM_UNION = 'TYPE_REMOVED_FROM_UNION', @@ -52,8 +52,9 @@ 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', @@ -61,6 +62,7 @@ export enum DangerousChangeType { IMPLEMENTED_INTERFACE_ADDED = 'IMPLEMENTED_INTERFACE_ADDED', ARG_DEFAULT_VALUE_CHANGE = 'ARG_DEFAULT_VALUE_CHANGE', } +export { DangerousChangeType }; export interface BreakingChange { type: BreakingChangeType;