@0no-co/graphql.web 0.1.2 → 0.1.4

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.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ <div align="center">
2
+ <h2>@0no-co/graphql.web</h2>
3
+ <strong>The spec-compliant minimum of client-side GraphQL.</strong>
4
+ <br />
5
+ <br />
6
+ <a href="https://github.com/0no-co/graphql.web/actions/workflows/release.yml">
7
+ <img alt="CI Status" src="https://github.com/0no-co/graphql.web/actions/workflows/release.yml/badge.svg?branch=main" />
8
+ </a>
9
+ <a href="https://npmjs.com/package/@0no-co/graphql.web">
10
+ <img alt="Bundlesize" src="https://deno.bundlejs.com/?q=@0no-co/graphql.web&badge" />
11
+ </a>
12
+ <a href="https://urql.dev/discord">
13
+ <img alt="Discord" src="https://img.shields.io/discord/1082378892523864074?color=7389D8&label&logo=discord&logoColor=ffffff" />
14
+ </a>
15
+ <br />
16
+ <br />
17
+ </div>
18
+
19
+ `@0no-co/graphql.web` is an **experimental** library, aiming to provide an
20
+ absolute minimum of features and exports of `graphql` utilities that typical
21
+ GraphQL web apps or GraphQL clients need.
22
+
23
+ While its goal isn’t to be an exact match to [the GraphQL.js
24
+ API](https://graphql.org/graphql-js/graphql/) it aims to provide API- and
25
+ type-compatible where possible and necessary. However, its goal is to provide
26
+ the smallest implementation for common GraphQL utilities that are still either
27
+ spec-compliant or compatible with GraphQL.js’ implementation.
28
+
29
+ > **Note:** While this library can be used as a drop-in replacement for
30
+ > `graphql` in _some cases_, the [`graphql-web-lite`
31
+ > project](https://github.com/0no-co/graphql-web-lite) is maintained to be
32
+ > a full shim/alias for the `graphql` package.
33
+
34
+ ### API
35
+
36
+ Currently, only a select few exports are provided — namely, the ones listed here
37
+ are used in `@urql/core`, and we expect them to be common in all client-side
38
+ GraphQL applications.
39
+
40
+ | Export | Description | Links |
41
+ | --- | ----------- | -------- |
42
+ | `parse` | A tiny (but compliant) GraphQL query language parser. | [Source](./src/parser.ts) |
43
+ | `print` | A (compliant) GraphQL query language printer. | [Source](./src/printer.ts) |
44
+ | `visit` | A recursive reimplementation of GraphQL.js’ visitor. | [Source](./src/printer.ts) |
45
+ | `Kind` | The GraphQL.js’ `Kind` enum, containing supported `ASTNode` kinds. | [Source](./src/kind.ts) |
46
+ | `GraphQLError` | `GraphQLError` stripped of source/location debugging. | [Source](./src/kind.ts) |
47
+ | `valueFromASTUntyped` | Coerces AST values into JS values. | [Source](./src/values.ts) |
48
+
49
+ The stated goals of any reimplementation are:
50
+ 1. Not to implement any execution or type system parts of the GraphQL
51
+ specification.
52
+ 2. To adhere to GraphQL.js’ types and APIs as much as possible.
53
+ 3. Not to implement or expose any rarely used APIs or properties of the
54
+ GraphQL.js library.
55
+ 4. To provide a minimal and maintainable subset of GraphQL.js utilities.
56
+
57
+ Therefore, while we can foresee implementing APIs that are entirely separate and
58
+ unrelated to the GraphQL.js library in the future, for now the stated goals are
59
+ designed to allow this library to be used by GraphQL clients, like
60
+ [`@urql/core`](https://github.com/urql-graphql/urql).
@@ -1,60 +1,251 @@
1
- declare enum Kind {
2
- /** Name */
3
- NAME = "Name",
4
- /** Document */
5
- DOCUMENT = "Document",
6
- OPERATION_DEFINITION = "OperationDefinition",
7
- VARIABLE_DEFINITION = "VariableDefinition",
8
- SELECTION_SET = "SelectionSet",
9
- FIELD = "Field",
10
- ARGUMENT = "Argument",
11
- /** Fragments */
12
- FRAGMENT_SPREAD = "FragmentSpread",
13
- INLINE_FRAGMENT = "InlineFragment",
14
- FRAGMENT_DEFINITION = "FragmentDefinition",
15
- /** Values */
16
- VARIABLE = "Variable",
17
- INT = "IntValue",
18
- FLOAT = "FloatValue",
19
- STRING = "StringValue",
20
- BOOLEAN = "BooleanValue",
21
- NULL = "NullValue",
22
- ENUM = "EnumValue",
23
- LIST = "ListValue",
24
- OBJECT = "ObjectValue",
25
- OBJECT_FIELD = "ObjectField",
26
- /** Directives */
27
- DIRECTIVE = "Directive",
28
- /** Types */
29
- NAMED_TYPE = "NamedType",
30
- LIST_TYPE = "ListType",
31
- NON_NULL_TYPE = "NonNullType"
32
- }
33
-
34
- interface Location {
35
- readonly start: number;
36
- readonly end: number;
37
- readonly source: Source;
1
+ type Maybe<T> = T | undefined | null;
2
+ interface Extensions {
3
+ [extension: string]: unknown;
38
4
  }
39
- interface Source {
5
+ type Source = any | {
40
6
  body: string;
41
7
  name: string;
42
8
  locationOffset: {
43
9
  line: number;
44
10
  column: number;
45
11
  };
12
+ };
13
+ type Location = any | {
14
+ start: number;
15
+ end: number;
16
+ source: Source;
17
+ };
18
+
19
+ declare enum Kind {
20
+ /** Name */
21
+ NAME = 'Name',
22
+ /** Document */
23
+ DOCUMENT = 'Document',
24
+ OPERATION_DEFINITION = 'OperationDefinition',
25
+ VARIABLE_DEFINITION = 'VariableDefinition',
26
+ SELECTION_SET = 'SelectionSet',
27
+ FIELD = 'Field',
28
+ ARGUMENT = 'Argument',
29
+ /** Fragments */
30
+ FRAGMENT_SPREAD = 'FragmentSpread',
31
+ INLINE_FRAGMENT = 'InlineFragment',
32
+ FRAGMENT_DEFINITION = 'FragmentDefinition',
33
+ /** Values */
34
+ VARIABLE = 'Variable',
35
+ INT = 'IntValue',
36
+ FLOAT = 'FloatValue',
37
+ STRING = 'StringValue',
38
+ BOOLEAN = 'BooleanValue',
39
+ NULL = 'NullValue',
40
+ ENUM = 'EnumValue',
41
+ LIST = 'ListValue',
42
+ OBJECT = 'ObjectValue',
43
+ OBJECT_FIELD = 'ObjectField',
44
+ /** Directives */
45
+ DIRECTIVE = 'Directive',
46
+ /** Types */
47
+ NAMED_TYPE = 'NamedType',
48
+ LIST_TYPE = 'ListType',
49
+ NON_NULL_TYPE = 'NonNullType',
50
+ /** Type System Definitions */
51
+ SCHEMA_DEFINITION = 'SchemaDefinition',
52
+ OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition',
53
+ /** Type Definitions */
54
+ SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition',
55
+ OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition',
56
+ FIELD_DEFINITION = 'FieldDefinition',
57
+ INPUT_VALUE_DEFINITION = 'InputValueDefinition',
58
+ INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition',
59
+ UNION_TYPE_DEFINITION = 'UnionTypeDefinition',
60
+ ENUM_TYPE_DEFINITION = 'EnumTypeDefinition',
61
+ ENUM_VALUE_DEFINITION = 'EnumValueDefinition',
62
+ INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition',
63
+ /** Directive Definitions */
64
+ DIRECTIVE_DEFINITION = 'DirectiveDefinition',
65
+ /** Type System Extensions */
66
+ SCHEMA_EXTENSION = 'SchemaExtension',
67
+ /** Type Extensions */
68
+ SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension',
69
+ OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension',
70
+ INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension',
71
+ UNION_TYPE_EXTENSION = 'UnionTypeExtension',
72
+ ENUM_TYPE_EXTENSION = 'EnumTypeExtension',
73
+ INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension',
74
+ }
75
+
76
+ declare enum OperationTypeNode {
77
+ QUERY = 'query',
78
+ MUTATION = 'mutation',
79
+ SUBSCRIPTION = 'subscription',
80
+ }
81
+
82
+ /** Type System Definition */
83
+ declare type TypeSystemDefinitionNode = SchemaDefinitionNode | TypeDefinitionNode | DirectiveDefinitionNode;
84
+ interface SchemaDefinitionNode {
85
+ readonly kind: Kind.SCHEMA_DEFINITION;
86
+ readonly loc?: Location;
87
+ readonly description?: StringValueNode;
88
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
89
+ readonly operationTypes: ReadonlyArray<OperationTypeDefinitionNode>;
90
+ }
91
+ interface OperationTypeDefinitionNode {
92
+ readonly kind: Kind.OPERATION_TYPE_DEFINITION;
93
+ readonly loc?: Location;
94
+ readonly operation: OperationTypeNode;
95
+ readonly type: NamedTypeNode;
96
+ }
97
+ /** Type Definition */
98
+ declare type TypeDefinitionNode = ScalarTypeDefinitionNode | ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode | InputObjectTypeDefinitionNode;
99
+ interface ScalarTypeDefinitionNode {
100
+ readonly kind: Kind.SCALAR_TYPE_DEFINITION;
101
+ readonly loc?: Location;
102
+ readonly description?: StringValueNode;
103
+ readonly name: NameNode;
104
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
105
+ }
106
+ interface ObjectTypeDefinitionNode {
107
+ readonly kind: Kind.OBJECT_TYPE_DEFINITION;
108
+ readonly loc?: Location;
109
+ readonly description?: StringValueNode;
110
+ readonly name: NameNode;
111
+ readonly interfaces?: ReadonlyArray<NamedTypeNode>;
112
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
113
+ readonly fields?: ReadonlyArray<FieldDefinitionNode>;
114
+ }
115
+ interface FieldDefinitionNode {
116
+ readonly kind: Kind.FIELD_DEFINITION;
117
+ readonly loc?: Location;
118
+ readonly description?: StringValueNode;
119
+ readonly name: NameNode;
120
+ readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
121
+ readonly type: TypeNode;
122
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
123
+ }
124
+ interface InputValueDefinitionNode {
125
+ readonly kind: Kind.INPUT_VALUE_DEFINITION;
126
+ readonly loc?: Location;
127
+ readonly description?: StringValueNode;
128
+ readonly name: NameNode;
129
+ readonly type: TypeNode;
130
+ readonly defaultValue?: ConstValueNode;
131
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
132
+ }
133
+ interface InterfaceTypeDefinitionNode {
134
+ readonly kind: Kind.INTERFACE_TYPE_DEFINITION;
135
+ readonly loc?: Location;
136
+ readonly description?: StringValueNode;
137
+ readonly name: NameNode;
138
+ readonly interfaces?: ReadonlyArray<NamedTypeNode>;
139
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
140
+ readonly fields?: ReadonlyArray<FieldDefinitionNode>;
141
+ }
142
+ interface UnionTypeDefinitionNode {
143
+ readonly kind: Kind.UNION_TYPE_DEFINITION;
144
+ readonly loc?: Location;
145
+ readonly description?: StringValueNode;
146
+ readonly name: NameNode;
147
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
148
+ readonly types?: ReadonlyArray<NamedTypeNode>;
149
+ }
150
+ interface EnumTypeDefinitionNode {
151
+ readonly kind: Kind.ENUM_TYPE_DEFINITION;
152
+ readonly loc?: Location;
153
+ readonly description?: StringValueNode;
154
+ readonly name: NameNode;
155
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
156
+ readonly values?: ReadonlyArray<EnumValueDefinitionNode>;
157
+ }
158
+ interface EnumValueDefinitionNode {
159
+ readonly kind: Kind.ENUM_VALUE_DEFINITION;
160
+ readonly loc?: Location;
161
+ readonly description?: StringValueNode;
162
+ readonly name: NameNode;
163
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
164
+ }
165
+ interface InputObjectTypeDefinitionNode {
166
+ readonly kind: Kind.INPUT_OBJECT_TYPE_DEFINITION;
167
+ readonly loc?: Location;
168
+ readonly description?: StringValueNode;
169
+ readonly name: NameNode;
170
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
171
+ readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
172
+ }
173
+ /** Directive Definitions */
174
+ interface DirectiveDefinitionNode {
175
+ readonly kind: Kind.DIRECTIVE_DEFINITION;
176
+ readonly loc?: Location;
177
+ readonly description?: StringValueNode;
178
+ readonly name: NameNode;
179
+ readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
180
+ readonly repeatable: boolean;
181
+ readonly locations: ReadonlyArray<NameNode>;
182
+ }
183
+ /** Type System Extensions */
184
+ declare type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode;
185
+ interface SchemaExtensionNode {
186
+ readonly kind: Kind.SCHEMA_EXTENSION;
187
+ readonly loc?: Location;
188
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
189
+ readonly operationTypes?: ReadonlyArray<OperationTypeDefinitionNode>;
190
+ }
191
+ /** Type Extensions */
192
+ declare type TypeExtensionNode = ScalarTypeExtensionNode | ObjectTypeExtensionNode | InterfaceTypeExtensionNode | UnionTypeExtensionNode | EnumTypeExtensionNode | InputObjectTypeExtensionNode;
193
+ interface ScalarTypeExtensionNode {
194
+ readonly kind: Kind.SCALAR_TYPE_EXTENSION;
195
+ readonly loc?: Location;
196
+ readonly name: NameNode;
197
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
198
+ }
199
+ interface ObjectTypeExtensionNode {
200
+ readonly kind: Kind.OBJECT_TYPE_EXTENSION;
201
+ readonly loc?: Location;
202
+ readonly name: NameNode;
203
+ readonly interfaces?: ReadonlyArray<NamedTypeNode>;
204
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
205
+ readonly fields?: ReadonlyArray<FieldDefinitionNode>;
206
+ }
207
+ interface InterfaceTypeExtensionNode {
208
+ readonly kind: Kind.INTERFACE_TYPE_EXTENSION;
209
+ readonly loc?: Location;
210
+ readonly name: NameNode;
211
+ readonly interfaces?: ReadonlyArray<NamedTypeNode>;
212
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
213
+ readonly fields?: ReadonlyArray<FieldDefinitionNode>;
46
214
  }
47
- declare type ASTNode = NameNode | DocumentNode | OperationDefinitionNode | VariableDefinitionNode | VariableNode | SelectionSetNode | FieldNode | ArgumentNode | FragmentSpreadNode | InlineFragmentNode | FragmentDefinitionNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode | ObjectFieldNode | DirectiveNode | NamedTypeNode | ListTypeNode | NonNullTypeNode;
215
+ interface UnionTypeExtensionNode {
216
+ readonly kind: Kind.UNION_TYPE_EXTENSION;
217
+ readonly loc?: Location;
218
+ readonly name: NameNode;
219
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
220
+ readonly types?: ReadonlyArray<NamedTypeNode>;
221
+ }
222
+ interface EnumTypeExtensionNode {
223
+ readonly kind: Kind.ENUM_TYPE_EXTENSION;
224
+ readonly loc?: Location;
225
+ readonly name: NameNode;
226
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
227
+ readonly values?: ReadonlyArray<EnumValueDefinitionNode>;
228
+ }
229
+ interface InputObjectTypeExtensionNode {
230
+ readonly kind: Kind.INPUT_OBJECT_TYPE_EXTENSION;
231
+ readonly loc?: Location;
232
+ readonly name: NameNode;
233
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
234
+ readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
235
+ }
236
+
237
+ type ASTNode = NameNode | DocumentNode | OperationDefinitionNode | VariableDefinitionNode | VariableNode | SelectionSetNode | FieldNode | ArgumentNode | FragmentSpreadNode | InlineFragmentNode | FragmentDefinitionNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode | ObjectFieldNode | DirectiveNode | NamedTypeNode | ListTypeNode | NonNullTypeNode | SchemaDefinitionNode | OperationTypeDefinitionNode | ScalarTypeDefinitionNode | ObjectTypeDefinitionNode | FieldDefinitionNode | InputValueDefinitionNode | InterfaceTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode | EnumValueDefinitionNode | InputObjectTypeDefinitionNode | DirectiveDefinitionNode | SchemaExtensionNode | ScalarTypeExtensionNode | ObjectTypeExtensionNode | InterfaceTypeExtensionNode | UnionTypeExtensionNode | EnumTypeExtensionNode | InputObjectTypeExtensionNode;
48
238
  interface NameNode {
49
239
  readonly kind: Kind.NAME;
50
240
  readonly value: string;
241
+ readonly loc?: Location;
51
242
  }
52
243
  interface DocumentNode {
53
244
  readonly kind: Kind.DOCUMENT;
54
- readonly definitions: ReadonlyArray<ExecutableDefinitionNode>;
245
+ readonly definitions: ReadonlyArray<DefinitionNode>;
55
246
  readonly loc?: Location;
56
247
  }
57
- type DefinitionNode = OperationDefinitionNode | FragmentDefinitionNode;
248
+ type DefinitionNode = ExecutableDefinitionNode | TypeSystemDefinitionNode | TypeSystemExtensionNode;
58
249
  type ExecutableDefinitionNode = OperationDefinitionNode | FragmentDefinitionNode;
59
250
  interface OperationDefinitionNode {
60
251
  readonly kind: Kind.OPERATION_DEFINITION;
@@ -63,11 +254,7 @@ interface OperationDefinitionNode {
63
254
  readonly variableDefinitions?: ReadonlyArray<VariableDefinitionNode>;
64
255
  readonly directives?: ReadonlyArray<DirectiveNode>;
65
256
  readonly selectionSet: SelectionSetNode;
66
- }
67
- declare const enum OperationTypeNode {
68
- QUERY = "query",
69
- MUTATION = "mutation",
70
- SUBSCRIPTION = "subscription"
257
+ readonly loc?: Location;
71
258
  }
72
259
  interface VariableDefinitionNode {
73
260
  readonly kind: Kind.VARIABLE_DEFINITION;
@@ -75,14 +262,17 @@ interface VariableDefinitionNode {
75
262
  readonly type: TypeNode;
76
263
  readonly defaultValue?: ConstValueNode;
77
264
  readonly directives?: ReadonlyArray<ConstDirectiveNode>;
265
+ readonly loc?: Location;
78
266
  }
79
267
  interface VariableNode {
80
268
  readonly kind: Kind.VARIABLE;
81
269
  readonly name: NameNode;
270
+ readonly loc?: Location;
82
271
  }
83
272
  interface SelectionSetNode {
84
- kind: Kind.SELECTION_SET;
85
- selections: ReadonlyArray<SelectionNode>;
273
+ readonly kind: Kind.SELECTION_SET;
274
+ readonly selections: ReadonlyArray<SelectionNode>;
275
+ readonly loc?: Location;
86
276
  }
87
277
  declare type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode;
88
278
  interface FieldNode {
@@ -92,27 +282,32 @@ interface FieldNode {
92
282
  readonly arguments?: ReadonlyArray<ArgumentNode>;
93
283
  readonly directives?: ReadonlyArray<DirectiveNode>;
94
284
  readonly selectionSet?: SelectionSetNode;
285
+ readonly loc?: Location;
95
286
  }
96
287
  interface ArgumentNode {
97
288
  readonly kind: Kind.ARGUMENT;
98
289
  readonly name: NameNode;
99
290
  readonly value: ValueNode;
291
+ readonly loc?: Location;
100
292
  }
101
293
  interface ConstArgumentNode {
102
294
  readonly kind: Kind.ARGUMENT;
103
295
  readonly name: NameNode;
104
296
  readonly value: ConstValueNode;
297
+ readonly loc?: Location;
105
298
  }
106
299
  interface FragmentSpreadNode {
107
300
  readonly kind: Kind.FRAGMENT_SPREAD;
108
301
  readonly name: NameNode;
109
302
  readonly directives?: ReadonlyArray<DirectiveNode>;
303
+ readonly loc?: Location;
110
304
  }
111
305
  interface InlineFragmentNode {
112
306
  readonly kind: Kind.INLINE_FRAGMENT;
113
307
  readonly typeCondition?: NamedTypeNode;
114
308
  readonly directives?: ReadonlyArray<DirectiveNode>;
115
309
  readonly selectionSet: SelectionSetNode;
310
+ readonly loc?: Location;
116
311
  }
117
312
  interface FragmentDefinitionNode {
118
313
  readonly kind: Kind.FRAGMENT_DEFINITION;
@@ -120,105 +315,122 @@ interface FragmentDefinitionNode {
120
315
  readonly typeCondition: NamedTypeNode;
121
316
  readonly directives?: ReadonlyArray<DirectiveNode>;
122
317
  readonly selectionSet: SelectionSetNode;
318
+ readonly loc?: Location;
123
319
  }
124
320
  type ValueNode = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode;
125
321
  type ConstValueNode = IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ConstListValueNode | ConstObjectValueNode;
126
322
  interface IntValueNode {
127
323
  readonly kind: Kind.INT;
128
324
  readonly value: string;
325
+ readonly loc?: Location;
129
326
  }
130
327
  interface FloatValueNode {
131
328
  readonly kind: Kind.FLOAT;
132
329
  readonly value: string;
330
+ readonly loc?: Location;
133
331
  }
134
332
  interface StringValueNode {
135
333
  readonly kind: Kind.STRING;
136
334
  readonly value: string;
137
335
  readonly block?: boolean;
336
+ readonly loc?: Location;
138
337
  }
139
338
  interface BooleanValueNode {
140
339
  readonly kind: Kind.BOOLEAN;
141
340
  readonly value: boolean;
341
+ readonly loc?: Location;
142
342
  }
143
343
  interface NullValueNode {
144
344
  readonly kind: Kind.NULL;
345
+ readonly loc?: Location;
145
346
  }
146
347
  interface EnumValueNode {
147
348
  readonly kind: Kind.ENUM;
148
349
  readonly value: string;
350
+ readonly loc?: Location;
149
351
  }
150
352
  interface ListValueNode {
151
353
  readonly kind: Kind.LIST;
152
354
  readonly values: ReadonlyArray<ValueNode>;
355
+ readonly loc?: Location;
153
356
  }
154
357
  interface ConstListValueNode {
155
358
  readonly kind: Kind.LIST;
156
359
  readonly values: ReadonlyArray<ConstValueNode>;
360
+ readonly loc?: Location;
157
361
  }
158
362
  interface ObjectValueNode {
159
363
  readonly kind: Kind.OBJECT;
160
364
  readonly fields: ReadonlyArray<ObjectFieldNode>;
365
+ readonly loc?: Location;
161
366
  }
162
367
  interface ConstObjectValueNode {
163
368
  readonly kind: Kind.OBJECT;
164
369
  readonly fields: ReadonlyArray<ConstObjectFieldNode>;
370
+ readonly loc?: Location;
165
371
  }
166
372
  interface ObjectFieldNode {
167
373
  readonly kind: Kind.OBJECT_FIELD;
168
374
  readonly name: NameNode;
169
375
  readonly value: ValueNode;
376
+ readonly loc?: Location;
170
377
  }
171
378
  interface ConstObjectFieldNode {
172
379
  readonly kind: Kind.OBJECT_FIELD;
173
380
  readonly name: NameNode;
174
381
  readonly value: ConstValueNode;
382
+ readonly loc?: Location;
175
383
  }
176
384
  interface DirectiveNode {
177
385
  readonly kind: Kind.DIRECTIVE;
178
386
  readonly name: NameNode;
179
387
  readonly arguments?: ReadonlyArray<ArgumentNode>;
388
+ readonly loc?: Location;
180
389
  }
181
390
  interface ConstDirectiveNode {
182
391
  readonly kind: Kind.DIRECTIVE;
183
392
  readonly name: NameNode;
184
393
  readonly arguments?: ReadonlyArray<ConstArgumentNode>;
394
+ readonly loc?: Location;
185
395
  }
186
396
  declare type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode;
187
397
  interface NamedTypeNode {
188
398
  readonly kind: Kind.NAMED_TYPE;
189
399
  readonly name: NameNode;
400
+ readonly loc?: Location;
190
401
  }
191
402
  interface ListTypeNode {
192
403
  readonly kind: Kind.LIST_TYPE;
193
404
  readonly type: TypeNode;
405
+ readonly loc?: Location;
194
406
  }
195
407
  interface NonNullTypeNode {
196
408
  readonly kind: Kind.NON_NULL_TYPE;
197
409
  readonly type: NamedTypeNode | ListTypeNode;
198
- }
199
-
200
- type Maybe<T> = T | undefined | null;
201
- interface Extensions {
202
- [extension: string]: unknown;
410
+ readonly loc?: Location;
203
411
  }
204
412
 
205
413
  declare class GraphQLError extends Error {
206
- readonly locations: undefined;
414
+ readonly locations: ReadonlyArray<any> | undefined;
207
415
  readonly path: ReadonlyArray<string | number> | undefined;
208
- readonly nodes: ReadonlyArray<ASTNode> | undefined;
416
+ readonly nodes: ReadonlyArray<any> | undefined;
209
417
  readonly source: Source | undefined;
210
418
  readonly positions: ReadonlyArray<number> | undefined;
211
419
  readonly originalError: Error | undefined;
212
420
  readonly extensions: Extensions;
213
421
  constructor(message: string, nodes?: ReadonlyArray<ASTNode> | ASTNode | null, source?: Maybe<Source>, positions?: Maybe<ReadonlyArray<number>>, path?: Maybe<ReadonlyArray<string | number>>, originalError?: Maybe<Error>, extensions?: Maybe<Extensions>);
214
- toJSON(): this;
422
+ toJSON(): any;
215
423
  toString(): string;
424
+ get [Symbol.toStringTag](): string;
216
425
  }
217
426
 
218
427
  declare function blockString(string: string): string;
219
- declare function parse(string: string): DocumentNode;
220
- declare function parseValue(string: string): ValueNode | undefined;
221
- declare function parseType(string: string): TypeNode | undefined;
428
+ type ParseOptions = {
429
+ [option: string]: any;
430
+ };
431
+ declare function parse(string: string | Source, _options?: ParseOptions | undefined): DocumentNode;
432
+ declare function parseValue(string: string | Source, _options?: ParseOptions | undefined): ValueNode;
433
+ declare function parseType(string: string | Source, _options?: ParseOptions | undefined): TypeNode;
222
434
 
223
435
  declare const BREAK: {};
224
436
  declare function visit<N extends ASTNode>(root: N, visitor: ASTVisitor): N;
@@ -247,4 +459,7 @@ declare function printString(string: string): string;
247
459
  declare function printBlockString(string: string): string;
248
460
  declare function print(node: ASTNode): string;
249
461
 
250
- export { ASTNode, ASTReducer, ASTVisitFn, ASTVisitor, ArgumentNode, BREAK, BooleanValueNode, ConstArgumentNode, ConstDirectiveNode, ConstListValueNode, ConstObjectFieldNode, ConstObjectValueNode, ConstValueNode, DefinitionNode, DirectiveNode, DocumentNode, EnumValueNode, ExecutableDefinitionNode, FieldNode, FloatValueNode, FragmentDefinitionNode, FragmentSpreadNode, GraphQLError, InlineFragmentNode, IntValueNode, Kind, ListTypeNode, ListValueNode, Location, NameNode, NamedTypeNode, NonNullTypeNode, NullValueNode, ObjectFieldNode, ObjectValueNode, OperationDefinitionNode, OperationTypeNode, SelectionNode, SelectionSetNode, Source, StringValueNode, TypeNode, ValueNode, VariableDefinitionNode, VariableNode, blockString, parse, parseType, parseValue, print, printBlockString, printString, visit };
462
+ declare function valueFromASTUntyped(node: ValueNode, variables?: Maybe<Record<string, any>>): unknown;
463
+ declare function valueFromTypeNode(node: ValueNode, type: TypeNode, variables?: Maybe<Record<string, any>>): unknown;
464
+
465
+ export { ASTNode, ASTReducer, ASTVisitFn, ASTVisitor, ArgumentNode, BREAK, BooleanValueNode, ConstArgumentNode, ConstDirectiveNode, ConstListValueNode, ConstObjectFieldNode, ConstObjectValueNode, ConstValueNode, DefinitionNode, DirectiveDefinitionNode, DirectiveNode, DocumentNode, EnumTypeDefinitionNode, EnumTypeExtensionNode, EnumValueDefinitionNode, EnumValueNode, ExecutableDefinitionNode, FieldDefinitionNode, FieldNode, FloatValueNode, FragmentDefinitionNode, FragmentSpreadNode, GraphQLError, InlineFragmentNode, InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode, InputValueDefinitionNode, IntValueNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode, Kind, ListTypeNode, ListValueNode, Location, NameNode, NamedTypeNode, NonNullTypeNode, NullValueNode, ObjectFieldNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, ObjectValueNode, OperationDefinitionNode, OperationTypeDefinitionNode, OperationTypeNode, ScalarTypeDefinitionNode, ScalarTypeExtensionNode, SchemaDefinitionNode, SchemaExtensionNode, SelectionNode, SelectionSetNode, Source, StringValueNode, TypeDefinitionNode, TypeExtensionNode, TypeNode, TypeSystemDefinitionNode, TypeSystemExtensionNode, UnionTypeDefinitionNode, UnionTypeExtensionNode, ValueNode, VariableDefinitionNode, VariableNode, blockString, parse, parseType, parseValue, print, printBlockString, printString, valueFromASTUntyped, valueFromTypeNode, visit };