Skip to content

Commit 64798c1

Browse files
committed
refactor: treeshakable kind enum
1 parent 16b3d01 commit 64798c1

File tree

2 files changed

+69
-73
lines changed

2 files changed

+69
-73
lines changed

src/language/kinds.ts

Lines changed: 4 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,8 @@
1-
/**
2-
* The set of allowed kind values for AST nodes.
3-
*/
4-
enum Kind {
5-
/** Name */
6-
NAME = 'Name',
7-
8-
/** Document */
9-
DOCUMENT = 'Document',
10-
OPERATION_DEFINITION = 'OperationDefinition',
11-
VARIABLE_DEFINITION = 'VariableDefinition',
12-
SELECTION_SET = 'SelectionSet',
13-
FIELD = 'Field',
14-
ARGUMENT = 'Argument',
15-
16-
/** Fragments */
17-
FRAGMENT_SPREAD = 'FragmentSpread',
18-
INLINE_FRAGMENT = 'InlineFragment',
19-
FRAGMENT_DEFINITION = 'FragmentDefinition',
20-
21-
/** Values */
22-
VARIABLE = 'Variable',
23-
INT = 'IntValue',
24-
FLOAT = 'FloatValue',
25-
STRING = 'StringValue',
26-
BOOLEAN = 'BooleanValue',
27-
NULL = 'NullValue',
28-
ENUM = 'EnumValue',
29-
LIST = 'ListValue',
30-
OBJECT = 'ObjectValue',
31-
OBJECT_FIELD = 'ObjectField',
32-
33-
/** Directives */
34-
DIRECTIVE = 'Directive',
1+
import * as kinds_ from './kinds_.js'; // eslint-disable-line
352

36-
/** Types */
37-
NAMED_TYPE = 'NamedType',
38-
LIST_TYPE = 'ListType',
39-
NON_NULL_TYPE = 'NonNullType',
40-
41-
/** Type System Definitions */
42-
SCHEMA_DEFINITION = 'SchemaDefinition',
43-
OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition',
44-
45-
/** Type Definitions */
46-
SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition',
47-
OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition',
48-
FIELD_DEFINITION = 'FieldDefinition',
49-
INPUT_VALUE_DEFINITION = 'InputValueDefinition',
50-
INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition',
51-
UNION_TYPE_DEFINITION = 'UnionTypeDefinition',
52-
ENUM_TYPE_DEFINITION = 'EnumTypeDefinition',
53-
ENUM_VALUE_DEFINITION = 'EnumValueDefinition',
54-
INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition',
55-
56-
/** Directive Definitions */
57-
DIRECTIVE_DEFINITION = 'DirectiveDefinition',
58-
59-
/** Type System Extensions */
60-
SCHEMA_EXTENSION = 'SchemaExtension',
61-
62-
/** Type Extensions */
63-
SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension',
64-
OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension',
65-
INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension',
66-
UNION_TYPE_EXTENSION = 'UnionTypeExtension',
67-
ENUM_TYPE_EXTENSION = 'EnumTypeExtension',
68-
INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension',
69-
}
70-
export { Kind };
3+
export * as Kind from './kinds_.js';
714

725
/**
73-
* The enum type representing the possible kind values of AST nodes.
74-
*
75-
* @deprecated Please use `Kind`. Will be remove in v17.
6+
* The set of allowed kind values for AST nodes.
767
*/
77-
export type KindEnum = typeof Kind;
8+
export type Kind = (typeof kinds_)[keyof typeof kinds_];

src/language/kinds_.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/** Name */
2+
export const NAME = 'Name';
3+
4+
/** Document */
5+
export const DOCUMENT = 'Document';
6+
export const OPERATION_DEFINITION = 'OperationDefinition';
7+
export const VARIABLE_DEFINITION = 'VariableDefinition';
8+
export const SELECTION_SET = 'SelectionSet';
9+
export const FIELD = 'Field';
10+
export const ARGUMENT = 'Argument';
11+
export const FRAGMENT_ARGUMENT = 'FragmentArgument';
12+
13+
/** Fragments */
14+
export const FRAGMENT_SPREAD = 'FragmentSpread';
15+
export const INLINE_FRAGMENT = 'InlineFragment';
16+
export const FRAGMENT_DEFINITION = 'FragmentDefinition';
17+
18+
/** Values */
19+
export const VARIABLE = 'Variable';
20+
export const INT = 'IntValue';
21+
export const FLOAT = 'FloatValue';
22+
export const STRING = 'StringValue';
23+
export const BOOLEAN = 'BooleanValue';
24+
export const NULL = 'NullValue';
25+
export const ENUM = 'EnumValue';
26+
export const LIST = 'ListValue';
27+
export const OBJECT = 'ObjectValue';
28+
export const OBJECT_FIELD = 'ObjectField';
29+
30+
/** Directives */
31+
export const DIRECTIVE = 'Directive';
32+
33+
/** Types */
34+
export const NAMED_TYPE = 'NamedType';
35+
export const LIST_TYPE = 'ListType';
36+
export const NON_NULL_TYPE = 'NonNullType';
37+
38+
/** Type System Definitions */
39+
export const SCHEMA_DEFINITION = 'SchemaDefinition';
40+
export const OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition';
41+
42+
/** Type Definitions */
43+
export const SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition';
44+
export const OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition';
45+
export const FIELD_DEFINITION = 'FieldDefinition';
46+
export const INPUT_VALUE_DEFINITION = 'InputValueDefinition';
47+
export const INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition';
48+
export const UNION_TYPE_DEFINITION = 'UnionTypeDefinition';
49+
export const ENUM_TYPE_DEFINITION = 'EnumTypeDefinition';
50+
export const ENUM_VALUE_DEFINITION = 'EnumValueDefinition';
51+
export const INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition';
52+
53+
/** Directive Definitions */
54+
export const DIRECTIVE_DEFINITION = 'DirectiveDefinition';
55+
56+
/** Type System Extensions */
57+
export const SCHEMA_EXTENSION = 'SchemaExtension';
58+
59+
/** Type Extensions */
60+
export const SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension';
61+
export const OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension';
62+
export const INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension';
63+
export const UNION_TYPE_EXTENSION = 'UnionTypeExtension';
64+
export const ENUM_TYPE_EXTENSION = 'EnumTypeExtension';
65+
export const INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension';

0 commit comments

Comments
 (0)