graphql 16.11.0 → 16.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +49 -6
  2. package/execution/execute.js +9 -0
  3. package/execution/execute.mjs +9 -0
  4. package/index.d.ts +11 -0
  5. package/index.js +24 -0
  6. package/index.mjs +6 -2
  7. package/language/ast.d.ts +45 -1
  8. package/language/ast.js +14 -1
  9. package/language/ast.mjs +14 -1
  10. package/language/index.d.ts +14 -1
  11. package/language/index.js +12 -0
  12. package/language/index.mjs +8 -1
  13. package/language/kinds.d.ts +6 -0
  14. package/language/kinds.js +5 -0
  15. package/language/kinds.mjs +5 -0
  16. package/language/lexer.d.ts +52 -1
  17. package/language/lexer.js +10 -0
  18. package/language/lexer.mjs +17 -4
  19. package/language/parser.d.ts +30 -3
  20. package/language/parser.js +129 -13
  21. package/language/parser.mjs +123 -11
  22. package/language/predicates.d.ts +4 -0
  23. package/language/predicates.js +11 -0
  24. package/language/predicates.mjs +9 -0
  25. package/language/printer.js +42 -13
  26. package/language/printer.mjs +42 -13
  27. package/language/schemaCoordinateLexer.d.ts +43 -0
  28. package/language/schemaCoordinateLexer.js +171 -0
  29. package/language/schemaCoordinateLexer.mjs +122 -0
  30. package/language/tokenKind.d.ts +1 -0
  31. package/language/tokenKind.js +1 -0
  32. package/language/tokenKind.mjs +1 -0
  33. package/package.json +1 -1
  34. package/utilities/index.d.ts +5 -0
  35. package/utilities/index.js +14 -0
  36. package/utilities/index.mjs +5 -0
  37. package/utilities/resolveSchemaCoordinate.d.ts +80 -0
  38. package/utilities/resolveSchemaCoordinate.js +260 -0
  39. package/utilities/resolveSchemaCoordinate.mjs +243 -0
  40. package/validation/rules/ValuesOfCorrectTypeRule.js +2 -36
  41. package/validation/rules/ValuesOfCorrectTypeRule.mjs +2 -35
  42. package/version.js +2 -2
  43. package/version.mjs +2 -2
package/README.md CHANGED
@@ -103,9 +103,9 @@ graphql({ schema, source }).then((result) => {
103
103
  });
104
104
  ```
105
105
 
106
- **Note**: Please don't forget to set `NODE_ENV=production` if you are running a production server. It will disable some checks that can be useful during development but will significantly improve performance.
106
+ **Note**: Please don't forget to set `NODE_ENV=production` if you are running a production server. It will disable some checks that can be useful during development but will significantly impact performance.
107
107
 
108
- ### Want to ride the bleeding edge?
108
+ ## Want to ride the bleeding edge?
109
109
 
110
110
  The `npm` branch in this repository is automatically maintained to be the last
111
111
  commit to `main` to pass all tests, in the same form found on npm. It is
@@ -127,7 +127,7 @@ Each release of GraphQL.js will be accompanied by an experimental release contai
127
127
 
128
128
  Community feedback on this experimental release is much appreciated and can be provided on the [issue created for this purpose](https://github.com/graphql/graphql-js/issues/2848).
129
129
 
130
- ### Using in a Browser
130
+ ## Using in a Browser
131
131
 
132
132
  GraphQL.js is a general-purpose library and can be used both in a Node server
133
133
  and in the browser. As an example, the [GraphiQL](https://github.com/graphql/graphiql/)
@@ -139,7 +139,7 @@ the portions of the library you use. This works because GraphQL.js is distribute
139
139
  with both CommonJS (`require()`) and ESModule (`import`) files. Ensure that any
140
140
  custom build configurations look for `.mjs` files!
141
141
 
142
- ### Contributing
142
+ ## Contributing
143
143
 
144
144
  We actively welcome pull requests. Learn how to [contribute](./.github/CONTRIBUTING.md).
145
145
 
@@ -151,10 +151,53 @@ You can find [detailed information here](https://github.com/graphql/graphql-wg/t
151
151
 
152
152
  If your company benefits from GraphQL and you would like to provide essential financial support for the systems and people that power our community, please also consider membership in the [GraphQL Foundation](https://foundation.graphql.org/join).
153
153
 
154
- ### Changelog
154
+ ## Changelog
155
155
 
156
156
  Changes are tracked as [GitHub releases](https://github.com/graphql/graphql-js/releases).
157
157
 
158
- ### License
158
+ ## License
159
159
 
160
160
  GraphQL.js is [MIT-licensed](./LICENSE).
161
+
162
+ ## Version Support
163
+
164
+ GraphQL.JS follows Semantic Versioning (SemVer) for its releases. Our version support policy is as follows:
165
+
166
+ - Latest Major Version: We provide full support, including bug fixes and security updates, for the latest major version of GraphQL.JS.
167
+ - Previous Major Version: We offer feature support for the previous major version for 12 months after the release of the newest major version.
168
+ This means that for 12 months we can backport features for specification changes _if_ they don't cause any breaking changes. We'll continue
169
+ supporting the previous major version with bug and security fixes.
170
+ - Older Versions: Versions older than the previous major release are considered unsupported. While the code remains available,
171
+ we do not actively maintain or provide updates for these versions.
172
+ One exception to this rule is when the older version has been released < 1 year ago, in that case we
173
+ will treat it like the "Previous Major Version".
174
+
175
+ ### Long-Term Support (LTS)
176
+
177
+ We do not currently offer a Long-Term Support version of GraphQL.JS. Users are encouraged to upgrade to the latest stable version
178
+ to receive the most up-to-date features, performance improvements, and security updates.
179
+
180
+ ### End-of-Life (EOL) Schedule
181
+
182
+ We will announce the EOL date for a major version at least 6 months in advance.
183
+ After a version reaches its EOL, it will no longer receive updates, even for critical security issues.
184
+
185
+ ### Upgrade Assistance
186
+
187
+ To assist users in upgrading to newer versions:
188
+
189
+ - We maintain detailed release notes for each version, highlighting new features, breaking changes, and deprecations.
190
+ - [Our documentation](https://www.graphql-js.org/) includes migration guides for moving between major versions.
191
+ - The [community forum (Discord channel #graphql-js)](https://discord.graphql.org) is available for users who need additional assistance with upgrades.
192
+
193
+ ### Security Updates
194
+
195
+ We prioritize the security of GraphQL.JS:
196
+
197
+ - Critical security updates will be applied to both the current and previous major version.
198
+ - For versions that have reached EOL, we strongly recommend upgrading to a supported version to receive security updates.
199
+
200
+ ### Community Contributions
201
+
202
+ We welcome community contributions for all versions of GraphQL.JS. However, our maintainers will primarily focus on reviewing
203
+ and merging contributions for supported versions.
@@ -974,6 +974,15 @@ const defaultTypeResolver = function (value, contextValue, info, abstractType) {
974
974
  if ((0, _isPromise.isPromise)(isTypeOfResult)) {
975
975
  promisedIsTypeOfResults[i] = isTypeOfResult;
976
976
  } else if (isTypeOfResult) {
977
+ if (promisedIsTypeOfResults.length) {
978
+ // Explicitly ignore any promise rejections
979
+ Promise.allSettled(promisedIsTypeOfResults)
980
+ /* c8 ignore next 3 */
981
+ .catch(() => {
982
+ // Do nothing
983
+ });
984
+ }
985
+
977
986
  return type.name;
978
987
  }
979
988
  }
@@ -945,6 +945,15 @@ export const defaultTypeResolver = function (
945
945
  if (isPromise(isTypeOfResult)) {
946
946
  promisedIsTypeOfResults[i] = isTypeOfResult;
947
947
  } else if (isTypeOfResult) {
948
+ if (promisedIsTypeOfResults.length) {
949
+ // Explicitly ignore any promise rejections
950
+ Promise.allSettled(promisedIsTypeOfResults)
951
+ /* c8 ignore next 3 */
952
+ .catch(() => {
953
+ // Do nothing
954
+ });
955
+ }
956
+
948
957
  return type.name;
949
958
  }
950
959
  }
package/index.d.ts CHANGED
@@ -190,6 +190,7 @@ export {
190
190
  parseValue,
191
191
  parseConstValue,
192
192
  parseType,
193
+ parseSchemaCoordinate,
193
194
  print,
194
195
  visit,
195
196
  visitInParallel,
@@ -208,6 +209,7 @@ export {
208
209
  isTypeDefinitionNode,
209
210
  isTypeSystemExtensionNode,
210
211
  isTypeExtensionNode,
212
+ isSchemaCoordinateNode,
211
213
  } from './language/index';
212
214
  export type {
213
215
  ParseOptions,
@@ -278,6 +280,12 @@ export type {
278
280
  UnionTypeExtensionNode,
279
281
  EnumTypeExtensionNode,
280
282
  InputObjectTypeExtensionNode,
283
+ SchemaCoordinateNode,
284
+ TypeCoordinateNode,
285
+ MemberCoordinateNode,
286
+ ArgumentCoordinateNode,
287
+ DirectiveCoordinateNode,
288
+ DirectiveArgumentCoordinateNode,
281
289
  } from './language/index';
282
290
  export {
283
291
  execute,
@@ -386,6 +394,8 @@ export {
386
394
  DangerousChangeType,
387
395
  findBreakingChanges,
388
396
  findDangerousChanges,
397
+ resolveSchemaCoordinate,
398
+ resolveASTSchemaCoordinate,
389
399
  } from './utilities/index';
390
400
  export type {
391
401
  IntrospectionOptions,
@@ -414,4 +424,5 @@ export type {
414
424
  BreakingChange,
415
425
  DangerousChange,
416
426
  TypedQueryDocumentNode,
427
+ ResolvedSchemaElement,
417
428
  } from './utilities/index';
package/index.js CHANGED
@@ -981,6 +981,12 @@ Object.defineProperty(exports, 'isSchema', {
981
981
  return _index.isSchema;
982
982
  },
983
983
  });
984
+ Object.defineProperty(exports, 'isSchemaCoordinateNode', {
985
+ enumerable: true,
986
+ get: function () {
987
+ return _index2.isSchemaCoordinateNode;
988
+ },
989
+ });
984
990
  Object.defineProperty(exports, 'isSelectionNode', {
985
991
  enumerable: true,
986
992
  get: function () {
@@ -1089,6 +1095,12 @@ Object.defineProperty(exports, 'parseConstValue', {
1089
1095
  return _index2.parseConstValue;
1090
1096
  },
1091
1097
  });
1098
+ Object.defineProperty(exports, 'parseSchemaCoordinate', {
1099
+ enumerable: true,
1100
+ get: function () {
1101
+ return _index2.parseSchemaCoordinate;
1102
+ },
1103
+ });
1092
1104
  Object.defineProperty(exports, 'parseType', {
1093
1105
  enumerable: true,
1094
1106
  get: function () {
@@ -1149,6 +1161,12 @@ Object.defineProperty(exports, 'recommendedRules', {
1149
1161
  return _index4.recommendedRules;
1150
1162
  },
1151
1163
  });
1164
+ Object.defineProperty(exports, 'resolveASTSchemaCoordinate', {
1165
+ enumerable: true,
1166
+ get: function () {
1167
+ return _index6.resolveASTSchemaCoordinate;
1168
+ },
1169
+ });
1152
1170
  Object.defineProperty(exports, 'resolveObjMapThunk', {
1153
1171
  enumerable: true,
1154
1172
  get: function () {
@@ -1161,6 +1179,12 @@ Object.defineProperty(exports, 'resolveReadonlyArrayThunk', {
1161
1179
  return _index.resolveReadonlyArrayThunk;
1162
1180
  },
1163
1181
  });
1182
+ Object.defineProperty(exports, 'resolveSchemaCoordinate', {
1183
+ enumerable: true,
1184
+ get: function () {
1185
+ return _index6.resolveSchemaCoordinate;
1186
+ },
1187
+ });
1164
1188
  Object.defineProperty(exports, 'responsePathAsArray', {
1165
1189
  enumerable: true,
1166
1190
  get: function () {
package/index.mjs CHANGED
@@ -135,7 +135,8 @@ export {
135
135
  parse,
136
136
  parseValue,
137
137
  parseConstValue,
138
- parseType, // Print
138
+ parseType,
139
+ parseSchemaCoordinate, // Print
139
140
  print, // Visit
140
141
  visit,
141
142
  visitInParallel,
@@ -154,6 +155,7 @@ export {
154
155
  isTypeDefinitionNode,
155
156
  isTypeSystemExtensionNode,
156
157
  isTypeExtensionNode,
158
+ isSchemaCoordinateNode,
157
159
  } from './language/index.mjs';
158
160
  // Execute GraphQL queries.
159
161
  export {
@@ -254,5 +256,7 @@ export {
254
256
  BreakingChangeType,
255
257
  DangerousChangeType,
256
258
  findBreakingChanges,
257
- findDangerousChanges,
259
+ findDangerousChanges, // Schema Coordinates
260
+ resolveSchemaCoordinate,
261
+ resolveASTSchemaCoordinate,
258
262
  } from './utilities/index.mjs';
package/language/ast.d.ts CHANGED
@@ -134,7 +134,12 @@ export declare type ASTNode =
134
134
  | InterfaceTypeExtensionNode
135
135
  | UnionTypeExtensionNode
136
136
  | EnumTypeExtensionNode
137
- | InputObjectTypeExtensionNode;
137
+ | InputObjectTypeExtensionNode
138
+ | TypeCoordinateNode
139
+ | MemberCoordinateNode
140
+ | ArgumentCoordinateNode
141
+ | DirectiveCoordinateNode
142
+ | DirectiveArgumentCoordinateNode;
138
143
  /**
139
144
  * Utility type listing all nodes indexed by their kind.
140
145
  */
@@ -173,6 +178,7 @@ export declare type ExecutableDefinitionNode =
173
178
  | FragmentDefinitionNode;
174
179
  export interface OperationDefinitionNode {
175
180
  readonly kind: Kind.OPERATION_DEFINITION;
181
+ readonly description?: StringValueNode;
176
182
  readonly loc?: Location;
177
183
  readonly operation: OperationTypeNode;
178
184
  readonly name?: NameNode;
@@ -188,6 +194,7 @@ declare enum OperationTypeNode {
188
194
  export { OperationTypeNode };
189
195
  export interface VariableDefinitionNode {
190
196
  readonly kind: Kind.VARIABLE_DEFINITION;
197
+ readonly description?: StringValueNode;
191
198
  readonly loc?: Location;
192
199
  readonly variable: VariableNode;
193
200
  readonly type: TypeNode;
@@ -245,6 +252,7 @@ export interface InlineFragmentNode {
245
252
  }
246
253
  export interface FragmentDefinitionNode {
247
254
  readonly kind: Kind.FRAGMENT_DEFINITION;
255
+ readonly description?: StringValueNode;
248
256
  readonly loc?: Location;
249
257
  readonly name: NameNode;
250
258
  /** @deprecated variableDefinitions will be removed in v17.0.0 */
@@ -536,3 +544,39 @@ export interface InputObjectTypeExtensionNode {
536
544
  readonly directives?: ReadonlyArray<ConstDirectiveNode>;
537
545
  readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
538
546
  }
547
+ /** Schema Coordinates */
548
+ export declare type SchemaCoordinateNode =
549
+ | TypeCoordinateNode
550
+ | MemberCoordinateNode
551
+ | ArgumentCoordinateNode
552
+ | DirectiveCoordinateNode
553
+ | DirectiveArgumentCoordinateNode;
554
+ export interface TypeCoordinateNode {
555
+ readonly kind: Kind.TYPE_COORDINATE;
556
+ readonly loc?: Location;
557
+ readonly name: NameNode;
558
+ }
559
+ export interface MemberCoordinateNode {
560
+ readonly kind: Kind.MEMBER_COORDINATE;
561
+ readonly loc?: Location;
562
+ readonly name: NameNode;
563
+ readonly memberName: NameNode;
564
+ }
565
+ export interface ArgumentCoordinateNode {
566
+ readonly kind: Kind.ARGUMENT_COORDINATE;
567
+ readonly loc?: Location;
568
+ readonly name: NameNode;
569
+ readonly fieldName: NameNode;
570
+ readonly argumentName: NameNode;
571
+ }
572
+ export interface DirectiveCoordinateNode {
573
+ readonly kind: Kind.DIRECTIVE_COORDINATE;
574
+ readonly loc?: Location;
575
+ readonly name: NameNode;
576
+ }
577
+ export interface DirectiveArgumentCoordinateNode {
578
+ readonly kind: Kind.DIRECTIVE_ARGUMENT_COORDINATE;
579
+ readonly loc?: Location;
580
+ readonly name: NameNode;
581
+ readonly argumentName: NameNode;
582
+ }
package/language/ast.js CHANGED
@@ -131,12 +131,19 @@ const QueryDocumentKeys = {
131
131
  Name: [],
132
132
  Document: ['definitions'],
133
133
  OperationDefinition: [
134
+ 'description',
134
135
  'name',
135
136
  'variableDefinitions',
136
137
  'directives',
137
138
  'selectionSet',
138
139
  ],
139
- VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'],
140
+ VariableDefinition: [
141
+ 'description',
142
+ 'variable',
143
+ 'type',
144
+ 'defaultValue',
145
+ 'directives',
146
+ ],
140
147
  Variable: ['name'],
141
148
  SelectionSet: ['selections'],
142
149
  Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
@@ -144,6 +151,7 @@ const QueryDocumentKeys = {
144
151
  FragmentSpread: ['name', 'directives'],
145
152
  InlineFragment: ['typeCondition', 'directives', 'selectionSet'],
146
153
  FragmentDefinition: [
154
+ 'description',
147
155
  'name', // Note: fragment variable definitions are deprecated and will removed in v17.0.0
148
156
  'variableDefinitions',
149
157
  'typeCondition',
@@ -200,6 +208,11 @@ const QueryDocumentKeys = {
200
208
  UnionTypeExtension: ['name', 'directives', 'types'],
201
209
  EnumTypeExtension: ['name', 'directives', 'values'],
202
210
  InputObjectTypeExtension: ['name', 'directives', 'fields'],
211
+ TypeCoordinate: ['name'],
212
+ MemberCoordinate: ['name', 'memberName'],
213
+ ArgumentCoordinate: ['name', 'fieldName', 'argumentName'],
214
+ DirectiveCoordinate: ['name'],
215
+ DirectiveArgumentCoordinate: ['name', 'argumentName'],
203
216
  };
204
217
  exports.QueryDocumentKeys = QueryDocumentKeys;
205
218
  const kindValues = new Set(Object.keys(QueryDocumentKeys));
package/language/ast.mjs CHANGED
@@ -115,12 +115,19 @@ export const QueryDocumentKeys = {
115
115
  Name: [],
116
116
  Document: ['definitions'],
117
117
  OperationDefinition: [
118
+ 'description',
118
119
  'name',
119
120
  'variableDefinitions',
120
121
  'directives',
121
122
  'selectionSet',
122
123
  ],
123
- VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'],
124
+ VariableDefinition: [
125
+ 'description',
126
+ 'variable',
127
+ 'type',
128
+ 'defaultValue',
129
+ 'directives',
130
+ ],
124
131
  Variable: ['name'],
125
132
  SelectionSet: ['selections'],
126
133
  Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
@@ -128,6 +135,7 @@ export const QueryDocumentKeys = {
128
135
  FragmentSpread: ['name', 'directives'],
129
136
  InlineFragment: ['typeCondition', 'directives', 'selectionSet'],
130
137
  FragmentDefinition: [
138
+ 'description',
131
139
  'name', // Note: fragment variable definitions are deprecated and will removed in v17.0.0
132
140
  'variableDefinitions',
133
141
  'typeCondition',
@@ -184,6 +192,11 @@ export const QueryDocumentKeys = {
184
192
  UnionTypeExtension: ['name', 'directives', 'types'],
185
193
  EnumTypeExtension: ['name', 'directives', 'values'],
186
194
  InputObjectTypeExtension: ['name', 'directives', 'fields'],
195
+ TypeCoordinate: ['name'],
196
+ MemberCoordinate: ['name', 'memberName'],
197
+ ArgumentCoordinate: ['name', 'fieldName', 'argumentName'],
198
+ DirectiveCoordinate: ['name'],
199
+ DirectiveArgumentCoordinate: ['name', 'argumentName'],
187
200
  };
188
201
  const kindValues = new Set(Object.keys(QueryDocumentKeys));
189
202
  /**
@@ -7,7 +7,13 @@ export type { KindEnum } from './kinds';
7
7
  export { TokenKind } from './tokenKind';
8
8
  export type { TokenKindEnum } from './tokenKind';
9
9
  export { Lexer } from './lexer';
10
- export { parse, parseValue, parseConstValue, parseType } from './parser';
10
+ export {
11
+ parse,
12
+ parseValue,
13
+ parseConstValue,
14
+ parseType,
15
+ parseSchemaCoordinate,
16
+ } from './parser';
11
17
  export type { ParseOptions } from './parser';
12
18
  export { print } from './printer';
13
19
  export {
@@ -80,6 +86,12 @@ export type {
80
86
  UnionTypeExtensionNode,
81
87
  EnumTypeExtensionNode,
82
88
  InputObjectTypeExtensionNode,
89
+ SchemaCoordinateNode,
90
+ TypeCoordinateNode,
91
+ MemberCoordinateNode,
92
+ ArgumentCoordinateNode,
93
+ DirectiveCoordinateNode,
94
+ DirectiveArgumentCoordinateNode,
83
95
  } from './ast';
84
96
  export {
85
97
  isDefinitionNode,
@@ -92,6 +104,7 @@ export {
92
104
  isTypeDefinitionNode,
93
105
  isTypeSystemExtensionNode,
94
106
  isTypeExtensionNode,
107
+ isSchemaCoordinateNode,
95
108
  } from './predicates';
96
109
  export { DirectiveLocation } from './directiveLocation';
97
110
  export type { DirectiveLocationEnum } from './directiveLocation';
package/language/index.js CHANGED
@@ -93,6 +93,12 @@ Object.defineProperty(exports, 'isExecutableDefinitionNode', {
93
93
  return _predicates.isExecutableDefinitionNode;
94
94
  },
95
95
  });
96
+ Object.defineProperty(exports, 'isSchemaCoordinateNode', {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _predicates.isSchemaCoordinateNode;
100
+ },
101
+ });
96
102
  Object.defineProperty(exports, 'isSelectionNode', {
97
103
  enumerable: true,
98
104
  get: function () {
@@ -147,6 +153,12 @@ Object.defineProperty(exports, 'parseConstValue', {
147
153
  return _parser.parseConstValue;
148
154
  },
149
155
  });
156
+ Object.defineProperty(exports, 'parseSchemaCoordinate', {
157
+ enumerable: true,
158
+ get: function () {
159
+ return _parser.parseSchemaCoordinate;
160
+ },
161
+ });
150
162
  Object.defineProperty(exports, 'parseType', {
151
163
  enumerable: true,
152
164
  get: function () {
@@ -4,7 +4,13 @@ export { printLocation, printSourceLocation } from './printLocation.mjs';
4
4
  export { Kind } from './kinds.mjs';
5
5
  export { TokenKind } from './tokenKind.mjs';
6
6
  export { Lexer } from './lexer.mjs';
7
- export { parse, parseValue, parseConstValue, parseType } from './parser.mjs';
7
+ export {
8
+ parse,
9
+ parseValue,
10
+ parseConstValue,
11
+ parseType,
12
+ parseSchemaCoordinate,
13
+ } from './parser.mjs';
8
14
  export { print } from './printer.mjs';
9
15
  export {
10
16
  visit,
@@ -25,5 +31,6 @@ export {
25
31
  isTypeDefinitionNode,
26
32
  isTypeSystemExtensionNode,
27
33
  isTypeExtensionNode,
34
+ isSchemaCoordinateNode,
28
35
  } from './predicates.mjs';
29
36
  export { DirectiveLocation } from './directiveLocation.mjs';
@@ -56,6 +56,12 @@ declare enum Kind {
56
56
  UNION_TYPE_EXTENSION = 'UnionTypeExtension',
57
57
  ENUM_TYPE_EXTENSION = 'EnumTypeExtension',
58
58
  INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension',
59
+ /** Schema Coordinates */
60
+ TYPE_COORDINATE = 'TypeCoordinate',
61
+ MEMBER_COORDINATE = 'MemberCoordinate',
62
+ ARGUMENT_COORDINATE = 'ArgumentCoordinate',
63
+ DIRECTIVE_COORDINATE = 'DirectiveCoordinate',
64
+ DIRECTIVE_ARGUMENT_COORDINATE = 'DirectiveArgumentCoordinate',
59
65
  }
60
66
  export { Kind };
61
67
  /**
package/language/kinds.js CHANGED
@@ -55,6 +55,11 @@ exports.Kind = Kind;
55
55
  Kind['UNION_TYPE_EXTENSION'] = 'UnionTypeExtension';
56
56
  Kind['ENUM_TYPE_EXTENSION'] = 'EnumTypeExtension';
57
57
  Kind['INPUT_OBJECT_TYPE_EXTENSION'] = 'InputObjectTypeExtension';
58
+ Kind['TYPE_COORDINATE'] = 'TypeCoordinate';
59
+ Kind['MEMBER_COORDINATE'] = 'MemberCoordinate';
60
+ Kind['ARGUMENT_COORDINATE'] = 'ArgumentCoordinate';
61
+ Kind['DIRECTIVE_COORDINATE'] = 'DirectiveCoordinate';
62
+ Kind['DIRECTIVE_ARGUMENT_COORDINATE'] = 'DirectiveArgumentCoordinate';
58
63
  })(Kind || (exports.Kind = Kind = {}));
59
64
  /**
60
65
  * The enum type representing the possible kind values of AST nodes.
@@ -47,6 +47,11 @@ var Kind;
47
47
  Kind['UNION_TYPE_EXTENSION'] = 'UnionTypeExtension';
48
48
  Kind['ENUM_TYPE_EXTENSION'] = 'EnumTypeExtension';
49
49
  Kind['INPUT_OBJECT_TYPE_EXTENSION'] = 'InputObjectTypeExtension';
50
+ Kind['TYPE_COORDINATE'] = 'TypeCoordinate';
51
+ Kind['MEMBER_COORDINATE'] = 'MemberCoordinate';
52
+ Kind['ARGUMENT_COORDINATE'] = 'ArgumentCoordinate';
53
+ Kind['DIRECTIVE_COORDINATE'] = 'DirectiveCoordinate';
54
+ Kind['DIRECTIVE_ARGUMENT_COORDINATE'] = 'DirectiveArgumentCoordinate';
50
55
  })(Kind || (Kind = {}));
51
56
 
52
57
  export { Kind };
@@ -1,6 +1,21 @@
1
1
  import { Token } from './ast';
2
2
  import type { Source } from './source';
3
3
  import { TokenKind } from './tokenKind';
4
+ /**
5
+ * A Lexer interface which provides common properties and methods required for
6
+ * lexing GraphQL source.
7
+ *
8
+ * @internal
9
+ */
10
+ export interface LexerInterface {
11
+ source: Source;
12
+ lastToken: Token;
13
+ token: Token;
14
+ line: number;
15
+ lineStart: number;
16
+ advance: () => Token;
17
+ lookahead: () => Token;
18
+ }
4
19
  /**
5
20
  * Given a Source object, creates a Lexer for that source.
6
21
  * A Lexer is a stateful stream generator in that every time
@@ -9,7 +24,7 @@ import { TokenKind } from './tokenKind';
9
24
  * EOF, after which the lexer will repeatedly return the same EOF token
10
25
  * whenever called.
11
26
  */
12
- export declare class Lexer {
27
+ export declare class Lexer implements LexerInterface {
13
28
  source: Source;
14
29
  /**
15
30
  * The previously focused non-ignored token.
@@ -43,3 +58,39 @@ export declare class Lexer {
43
58
  * @internal
44
59
  */
45
60
  export declare function isPunctuatorTokenKind(kind: TokenKind): boolean;
61
+ /**
62
+ * Prints the code point (or end of file reference) at a given location in a
63
+ * source for use in error messages.
64
+ *
65
+ * Printable ASCII is printed quoted, while other points are printed in Unicode
66
+ * code point form (ie. U+1234).
67
+ *
68
+ * @internal
69
+ */
70
+ export declare function printCodePointAt(
71
+ lexer: LexerInterface,
72
+ location: number,
73
+ ): string;
74
+ /**
75
+ * Create a token with line and column location information.
76
+ *
77
+ * @internal
78
+ */
79
+ export declare function createToken(
80
+ lexer: LexerInterface,
81
+ kind: TokenKind,
82
+ start: number,
83
+ end: number,
84
+ value?: string,
85
+ ): Token;
86
+ /**
87
+ * Reads an alphanumeric + underscore name from the source.
88
+ *
89
+ * ```
90
+ * Name ::
91
+ * - NameStart NameContinue* [lookahead != NameContinue]
92
+ * ```
93
+ *
94
+ * @internal
95
+ */
96
+ export declare function readName(lexer: LexerInterface, start: number): Token;
package/language/lexer.js CHANGED
@@ -4,7 +4,10 @@ Object.defineProperty(exports, '__esModule', {
4
4
  value: true,
5
5
  });
6
6
  exports.Lexer = void 0;
7
+ exports.createToken = createToken;
7
8
  exports.isPunctuatorTokenKind = isPunctuatorTokenKind;
9
+ exports.printCodePointAt = printCodePointAt;
10
+ exports.readName = readName;
8
11
 
9
12
  var _syntaxError = require('../error/syntaxError.js');
10
13
 
@@ -107,6 +110,7 @@ function isPunctuatorTokenKind(kind) {
107
110
  kind === _tokenKind.TokenKind.AMP ||
108
111
  kind === _tokenKind.TokenKind.PAREN_L ||
109
112
  kind === _tokenKind.TokenKind.PAREN_R ||
113
+ kind === _tokenKind.TokenKind.DOT ||
110
114
  kind === _tokenKind.TokenKind.SPREAD ||
111
115
  kind === _tokenKind.TokenKind.COLON ||
112
116
  kind === _tokenKind.TokenKind.EQUALS ||
@@ -161,6 +165,8 @@ function isTrailingSurrogate(code) {
161
165
  *
162
166
  * Printable ASCII is printed quoted, while other points are printed in Unicode
163
167
  * code point form (ie. U+1234).
168
+ *
169
+ * @internal
164
170
  */
165
171
 
166
172
  function printCodePointAt(lexer, location) {
@@ -178,6 +184,8 @@ function printCodePointAt(lexer, location) {
178
184
  }
179
185
  /**
180
186
  * Create a token with line and column location information.
187
+ *
188
+ * @internal
181
189
  */
182
190
 
183
191
  function createToken(lexer, kind, start, end, value) {
@@ -979,6 +987,8 @@ function readBlockString(lexer, start) {
979
987
  * Name ::
980
988
  * - NameStart NameContinue* [lookahead != NameContinue]
981
989
  * ```
990
+ *
991
+ * @internal
982
992
  */
983
993
 
984
994
  function readName(lexer, start) {