@0no-co/graphql.web 0.0.0-canary-20230320141923
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/LICENSE.md +21 -0
- package/README.md +60 -0
- package/dist/graphql.web.d.ts +465 -0
- package/dist/graphql.web.js +873 -0
- package/dist/graphql.web.js.map +1 -0
- package/dist/graphql.web.mjs +859 -0
- package/dist/graphql.web.mjs.map +1 -0
- package/package.json +97 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 0no.co
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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).
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
type Maybe<T> = T | undefined | null;
|
|
2
|
+
interface Extensions {
|
|
3
|
+
[extension: string]: unknown;
|
|
4
|
+
}
|
|
5
|
+
type Source = any | {
|
|
6
|
+
body: string;
|
|
7
|
+
name: string;
|
|
8
|
+
locationOffset: {
|
|
9
|
+
line: number;
|
|
10
|
+
column: number;
|
|
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>;
|
|
214
|
+
}
|
|
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;
|
|
238
|
+
interface NameNode {
|
|
239
|
+
readonly kind: Kind.NAME;
|
|
240
|
+
readonly value: string;
|
|
241
|
+
readonly loc?: Location;
|
|
242
|
+
}
|
|
243
|
+
interface DocumentNode {
|
|
244
|
+
readonly kind: Kind.DOCUMENT;
|
|
245
|
+
readonly definitions: ReadonlyArray<DefinitionNode>;
|
|
246
|
+
readonly loc?: Location;
|
|
247
|
+
}
|
|
248
|
+
type DefinitionNode = ExecutableDefinitionNode | TypeSystemDefinitionNode | TypeSystemExtensionNode;
|
|
249
|
+
type ExecutableDefinitionNode = OperationDefinitionNode | FragmentDefinitionNode;
|
|
250
|
+
interface OperationDefinitionNode {
|
|
251
|
+
readonly kind: Kind.OPERATION_DEFINITION;
|
|
252
|
+
readonly operation: OperationTypeNode;
|
|
253
|
+
readonly name?: NameNode;
|
|
254
|
+
readonly variableDefinitions?: ReadonlyArray<VariableDefinitionNode>;
|
|
255
|
+
readonly directives?: ReadonlyArray<DirectiveNode>;
|
|
256
|
+
readonly selectionSet: SelectionSetNode;
|
|
257
|
+
readonly loc?: Location;
|
|
258
|
+
}
|
|
259
|
+
interface VariableDefinitionNode {
|
|
260
|
+
readonly kind: Kind.VARIABLE_DEFINITION;
|
|
261
|
+
readonly variable: VariableNode;
|
|
262
|
+
readonly type: TypeNode;
|
|
263
|
+
readonly defaultValue?: ConstValueNode;
|
|
264
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
|
|
265
|
+
readonly loc?: Location;
|
|
266
|
+
}
|
|
267
|
+
interface VariableNode {
|
|
268
|
+
readonly kind: Kind.VARIABLE;
|
|
269
|
+
readonly name: NameNode;
|
|
270
|
+
readonly loc?: Location;
|
|
271
|
+
}
|
|
272
|
+
interface SelectionSetNode {
|
|
273
|
+
readonly kind: Kind.SELECTION_SET;
|
|
274
|
+
readonly selections: ReadonlyArray<SelectionNode>;
|
|
275
|
+
readonly loc?: Location;
|
|
276
|
+
}
|
|
277
|
+
declare type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode;
|
|
278
|
+
interface FieldNode {
|
|
279
|
+
readonly kind: Kind.FIELD;
|
|
280
|
+
readonly alias?: NameNode;
|
|
281
|
+
readonly name: NameNode;
|
|
282
|
+
readonly arguments?: ReadonlyArray<ArgumentNode>;
|
|
283
|
+
readonly directives?: ReadonlyArray<DirectiveNode>;
|
|
284
|
+
readonly selectionSet?: SelectionSetNode;
|
|
285
|
+
readonly loc?: Location;
|
|
286
|
+
}
|
|
287
|
+
interface ArgumentNode {
|
|
288
|
+
readonly kind: Kind.ARGUMENT;
|
|
289
|
+
readonly name: NameNode;
|
|
290
|
+
readonly value: ValueNode;
|
|
291
|
+
readonly loc?: Location;
|
|
292
|
+
}
|
|
293
|
+
interface ConstArgumentNode {
|
|
294
|
+
readonly kind: Kind.ARGUMENT;
|
|
295
|
+
readonly name: NameNode;
|
|
296
|
+
readonly value: ConstValueNode;
|
|
297
|
+
readonly loc?: Location;
|
|
298
|
+
}
|
|
299
|
+
interface FragmentSpreadNode {
|
|
300
|
+
readonly kind: Kind.FRAGMENT_SPREAD;
|
|
301
|
+
readonly name: NameNode;
|
|
302
|
+
readonly directives?: ReadonlyArray<DirectiveNode>;
|
|
303
|
+
readonly loc?: Location;
|
|
304
|
+
}
|
|
305
|
+
interface InlineFragmentNode {
|
|
306
|
+
readonly kind: Kind.INLINE_FRAGMENT;
|
|
307
|
+
readonly typeCondition?: NamedTypeNode;
|
|
308
|
+
readonly directives?: ReadonlyArray<DirectiveNode>;
|
|
309
|
+
readonly selectionSet: SelectionSetNode;
|
|
310
|
+
readonly loc?: Location;
|
|
311
|
+
}
|
|
312
|
+
interface FragmentDefinitionNode {
|
|
313
|
+
readonly kind: Kind.FRAGMENT_DEFINITION;
|
|
314
|
+
readonly name: NameNode;
|
|
315
|
+
readonly typeCondition: NamedTypeNode;
|
|
316
|
+
readonly directives?: ReadonlyArray<DirectiveNode>;
|
|
317
|
+
readonly selectionSet: SelectionSetNode;
|
|
318
|
+
readonly loc?: Location;
|
|
319
|
+
}
|
|
320
|
+
type ValueNode = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode;
|
|
321
|
+
type ConstValueNode = IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ConstListValueNode | ConstObjectValueNode;
|
|
322
|
+
interface IntValueNode {
|
|
323
|
+
readonly kind: Kind.INT;
|
|
324
|
+
readonly value: string;
|
|
325
|
+
readonly loc?: Location;
|
|
326
|
+
}
|
|
327
|
+
interface FloatValueNode {
|
|
328
|
+
readonly kind: Kind.FLOAT;
|
|
329
|
+
readonly value: string;
|
|
330
|
+
readonly loc?: Location;
|
|
331
|
+
}
|
|
332
|
+
interface StringValueNode {
|
|
333
|
+
readonly kind: Kind.STRING;
|
|
334
|
+
readonly value: string;
|
|
335
|
+
readonly block?: boolean;
|
|
336
|
+
readonly loc?: Location;
|
|
337
|
+
}
|
|
338
|
+
interface BooleanValueNode {
|
|
339
|
+
readonly kind: Kind.BOOLEAN;
|
|
340
|
+
readonly value: boolean;
|
|
341
|
+
readonly loc?: Location;
|
|
342
|
+
}
|
|
343
|
+
interface NullValueNode {
|
|
344
|
+
readonly kind: Kind.NULL;
|
|
345
|
+
readonly loc?: Location;
|
|
346
|
+
}
|
|
347
|
+
interface EnumValueNode {
|
|
348
|
+
readonly kind: Kind.ENUM;
|
|
349
|
+
readonly value: string;
|
|
350
|
+
readonly loc?: Location;
|
|
351
|
+
}
|
|
352
|
+
interface ListValueNode {
|
|
353
|
+
readonly kind: Kind.LIST;
|
|
354
|
+
readonly values: ReadonlyArray<ValueNode>;
|
|
355
|
+
readonly loc?: Location;
|
|
356
|
+
}
|
|
357
|
+
interface ConstListValueNode {
|
|
358
|
+
readonly kind: Kind.LIST;
|
|
359
|
+
readonly values: ReadonlyArray<ConstValueNode>;
|
|
360
|
+
readonly loc?: Location;
|
|
361
|
+
}
|
|
362
|
+
interface ObjectValueNode {
|
|
363
|
+
readonly kind: Kind.OBJECT;
|
|
364
|
+
readonly fields: ReadonlyArray<ObjectFieldNode>;
|
|
365
|
+
readonly loc?: Location;
|
|
366
|
+
}
|
|
367
|
+
interface ConstObjectValueNode {
|
|
368
|
+
readonly kind: Kind.OBJECT;
|
|
369
|
+
readonly fields: ReadonlyArray<ConstObjectFieldNode>;
|
|
370
|
+
readonly loc?: Location;
|
|
371
|
+
}
|
|
372
|
+
interface ObjectFieldNode {
|
|
373
|
+
readonly kind: Kind.OBJECT_FIELD;
|
|
374
|
+
readonly name: NameNode;
|
|
375
|
+
readonly value: ValueNode;
|
|
376
|
+
readonly loc?: Location;
|
|
377
|
+
}
|
|
378
|
+
interface ConstObjectFieldNode {
|
|
379
|
+
readonly kind: Kind.OBJECT_FIELD;
|
|
380
|
+
readonly name: NameNode;
|
|
381
|
+
readonly value: ConstValueNode;
|
|
382
|
+
readonly loc?: Location;
|
|
383
|
+
}
|
|
384
|
+
interface DirectiveNode {
|
|
385
|
+
readonly kind: Kind.DIRECTIVE;
|
|
386
|
+
readonly name: NameNode;
|
|
387
|
+
readonly arguments?: ReadonlyArray<ArgumentNode>;
|
|
388
|
+
readonly loc?: Location;
|
|
389
|
+
}
|
|
390
|
+
interface ConstDirectiveNode {
|
|
391
|
+
readonly kind: Kind.DIRECTIVE;
|
|
392
|
+
readonly name: NameNode;
|
|
393
|
+
readonly arguments?: ReadonlyArray<ConstArgumentNode>;
|
|
394
|
+
readonly loc?: Location;
|
|
395
|
+
}
|
|
396
|
+
declare type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode;
|
|
397
|
+
interface NamedTypeNode {
|
|
398
|
+
readonly kind: Kind.NAMED_TYPE;
|
|
399
|
+
readonly name: NameNode;
|
|
400
|
+
readonly loc?: Location;
|
|
401
|
+
}
|
|
402
|
+
interface ListTypeNode {
|
|
403
|
+
readonly kind: Kind.LIST_TYPE;
|
|
404
|
+
readonly type: TypeNode;
|
|
405
|
+
readonly loc?: Location;
|
|
406
|
+
}
|
|
407
|
+
interface NonNullTypeNode {
|
|
408
|
+
readonly kind: Kind.NON_NULL_TYPE;
|
|
409
|
+
readonly type: NamedTypeNode | ListTypeNode;
|
|
410
|
+
readonly loc?: Location;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
declare class GraphQLError extends Error {
|
|
414
|
+
readonly locations: ReadonlyArray<any> | undefined;
|
|
415
|
+
readonly path: ReadonlyArray<string | number> | undefined;
|
|
416
|
+
readonly nodes: ReadonlyArray<any> | undefined;
|
|
417
|
+
readonly source: Source | undefined;
|
|
418
|
+
readonly positions: ReadonlyArray<number> | undefined;
|
|
419
|
+
readonly originalError: Error | undefined;
|
|
420
|
+
readonly extensions: Extensions;
|
|
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>);
|
|
422
|
+
toJSON(): any;
|
|
423
|
+
toString(): string;
|
|
424
|
+
get [Symbol.toStringTag](): string;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
declare function blockString(string: string): string;
|
|
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;
|
|
434
|
+
|
|
435
|
+
declare const BREAK: {};
|
|
436
|
+
declare function visit<N extends ASTNode>(root: N, visitor: ASTVisitor): N;
|
|
437
|
+
declare function visit<R>(root: ASTNode, visitor: ASTReducer<R>): R;
|
|
438
|
+
type ASTVisitor = EnterLeaveVisitor<ASTNode> | KindVisitor;
|
|
439
|
+
type KindVisitor = {
|
|
440
|
+
readonly [NodeT in ASTNode as NodeT['kind']]?: ASTVisitFn<NodeT> | EnterLeaveVisitor<NodeT>;
|
|
441
|
+
};
|
|
442
|
+
interface EnterLeaveVisitor<TVisitedNode extends ASTNode> {
|
|
443
|
+
readonly enter?: ASTVisitFn<TVisitedNode> | undefined;
|
|
444
|
+
readonly leave?: ASTVisitFn<TVisitedNode> | undefined;
|
|
445
|
+
}
|
|
446
|
+
type ASTVisitFn<Node extends ASTNode> = (node: Node, key: string | number | undefined, parent: ASTNode | ReadonlyArray<ASTNode> | undefined, path: ReadonlyArray<string | number>, ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>) => any;
|
|
447
|
+
type ASTReducer<R> = {
|
|
448
|
+
readonly [NodeT in ASTNode as NodeT['kind']]?: {
|
|
449
|
+
readonly enter?: ASTVisitFn<NodeT>;
|
|
450
|
+
readonly leave: ASTReducerFn<NodeT, R>;
|
|
451
|
+
};
|
|
452
|
+
};
|
|
453
|
+
type ASTReducerFn<TReducedNode extends ASTNode, R> = (node: {
|
|
454
|
+
[K in keyof TReducedNode]: ReducedField<TReducedNode[K], R>;
|
|
455
|
+
}, key: string | number | undefined, parent: ASTNode | ReadonlyArray<ASTNode> | undefined, path: ReadonlyArray<string | number>, ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>) => R;
|
|
456
|
+
type ReducedField<T, R> = T extends null | undefined ? T : T extends ReadonlyArray<any> ? ReadonlyArray<R> : R;
|
|
457
|
+
|
|
458
|
+
declare function printString(string: string): string;
|
|
459
|
+
declare function printBlockString(string: string): string;
|
|
460
|
+
declare function print(node: ASTNode): string;
|
|
461
|
+
|
|
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 };
|