@0no-co/graphql.web 0.1.0 → 0.1.2
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/dist/graphql.web.d.ts +250 -0
- package/dist/graphql.web.js +804 -0
- package/dist/graphql.web.js.map +1 -0
- package/dist/graphql.web.mjs +792 -0
- package/dist/graphql.web.mjs.map +1 -0
- package/package.json +7 -2
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -7
- package/.gitattributes +0 -1
- package/.github/workflows/ci.yml +0 -57
- package/.github/workflows/release.yml +0 -63
- package/benchmark/kitchen_sink.graphql +0 -69
- package/benchmark/package.json +0 -14
- package/benchmark/suite.js +0 -26
- package/pnpm-workspace.yaml +0 -2
- package/scripts/changelog.js +0 -125
- package/scripts/eslint-preset.js +0 -54
- package/scripts/prepare.js +0 -18
- package/scripts/rollup.config.mjs +0 -160
- package/src/__tests__/__snapshots__/parser.test.ts.snap +0 -779
- package/src/__tests__/parser.test.ts +0 -11
- package/src/ast.ts +0 -251
- package/src/error.ts +0 -51
- package/src/index.ts +0 -6
- package/src/kind.ts +0 -32
- package/src/parser.ts +0 -480
- package/src/printer.ts +0 -132
- package/src/types.ts +0 -5
- package/src/visitor.ts +0 -136
- package/tsconfig.json +0 -24
|
@@ -0,0 +1,804 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: !0
|
|
3
|
+
});
|
|
4
|
+
|
|
5
|
+
exports.OperationTypeNode = void 0;
|
|
6
|
+
|
|
7
|
+
!function(e) {
|
|
8
|
+
e.QUERY = "query";
|
|
9
|
+
e.MUTATION = "mutation";
|
|
10
|
+
e.SUBSCRIPTION = "subscription";
|
|
11
|
+
}(exports.OperationTypeNode || (exports.OperationTypeNode = {}));
|
|
12
|
+
|
|
13
|
+
exports.Kind = void 0;
|
|
14
|
+
|
|
15
|
+
!function(e) {
|
|
16
|
+
e.NAME = "Name";
|
|
17
|
+
e.DOCUMENT = "Document";
|
|
18
|
+
e.OPERATION_DEFINITION = "OperationDefinition";
|
|
19
|
+
e.VARIABLE_DEFINITION = "VariableDefinition";
|
|
20
|
+
e.SELECTION_SET = "SelectionSet";
|
|
21
|
+
e.FIELD = "Field";
|
|
22
|
+
e.ARGUMENT = "Argument";
|
|
23
|
+
e.FRAGMENT_SPREAD = "FragmentSpread";
|
|
24
|
+
e.INLINE_FRAGMENT = "InlineFragment";
|
|
25
|
+
e.FRAGMENT_DEFINITION = "FragmentDefinition";
|
|
26
|
+
e.VARIABLE = "Variable";
|
|
27
|
+
e.INT = "IntValue";
|
|
28
|
+
e.FLOAT = "FloatValue";
|
|
29
|
+
e.STRING = "StringValue";
|
|
30
|
+
e.BOOLEAN = "BooleanValue";
|
|
31
|
+
e.NULL = "NullValue";
|
|
32
|
+
e.ENUM = "EnumValue";
|
|
33
|
+
e.LIST = "ListValue";
|
|
34
|
+
e.OBJECT = "ObjectValue";
|
|
35
|
+
e.OBJECT_FIELD = "ObjectField";
|
|
36
|
+
e.DIRECTIVE = "Directive";
|
|
37
|
+
e.NAMED_TYPE = "NamedType";
|
|
38
|
+
e.LIST_TYPE = "ListType";
|
|
39
|
+
e.NON_NULL_TYPE = "NonNullType";
|
|
40
|
+
}(exports.Kind || (exports.Kind = {}));
|
|
41
|
+
|
|
42
|
+
class GraphQLError extends Error {
|
|
43
|
+
constructor(e, r, i, n, t, o, a) {
|
|
44
|
+
super(e);
|
|
45
|
+
this.name = "GraphQLError";
|
|
46
|
+
this.message = e;
|
|
47
|
+
if (t) {
|
|
48
|
+
this.path = t;
|
|
49
|
+
}
|
|
50
|
+
if (r) {
|
|
51
|
+
this.nodes = Array.isArray(r) ? r : [ r ];
|
|
52
|
+
}
|
|
53
|
+
if (i) {
|
|
54
|
+
this.source = i;
|
|
55
|
+
}
|
|
56
|
+
if (n) {
|
|
57
|
+
this.positions = n;
|
|
58
|
+
}
|
|
59
|
+
if (o) {
|
|
60
|
+
this.originalError = o;
|
|
61
|
+
}
|
|
62
|
+
if (!a && o) {
|
|
63
|
+
var s = o.extensions;
|
|
64
|
+
if (s && "object" == typeof s) {
|
|
65
|
+
s;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
this.extensions = a || {};
|
|
69
|
+
}
|
|
70
|
+
toJSON() {
|
|
71
|
+
return {
|
|
72
|
+
...this
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
toString() {
|
|
76
|
+
return this.message;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
var e;
|
|
81
|
+
|
|
82
|
+
var r;
|
|
83
|
+
|
|
84
|
+
function error(e) {
|
|
85
|
+
return new GraphQLError(`Syntax Error: Unexpected token at ${r} in ${e}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function advance(i) {
|
|
89
|
+
i.lastIndex = r;
|
|
90
|
+
if (i.test(e)) {
|
|
91
|
+
return e.slice(r, r = i.lastIndex);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
var i = / +(?=[^\s])/y;
|
|
96
|
+
|
|
97
|
+
function blockString(e) {
|
|
98
|
+
var r = "";
|
|
99
|
+
var n = 0;
|
|
100
|
+
var t = 0;
|
|
101
|
+
var o = -1;
|
|
102
|
+
var a = e.split("\n");
|
|
103
|
+
for (var s = 0; s < a.length; s++) {
|
|
104
|
+
i.lastIndex = 0;
|
|
105
|
+
if (i.test(a[s])) {
|
|
106
|
+
if (s && (!n || i.lastIndex < n)) {
|
|
107
|
+
n = i.lastIndex;
|
|
108
|
+
}
|
|
109
|
+
t = t || s;
|
|
110
|
+
o = s;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (var d = t; d <= o; d++) {
|
|
114
|
+
if (d !== t) {
|
|
115
|
+
r += "\n";
|
|
116
|
+
}
|
|
117
|
+
r += a[d].slice(n).replace(/\\"""/g, '"""');
|
|
118
|
+
}
|
|
119
|
+
return r;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
var n = /(?:[\s,]*|#[^\n\r]*)*/y;
|
|
123
|
+
|
|
124
|
+
function ignored() {
|
|
125
|
+
n.lastIndex = r;
|
|
126
|
+
n.test(e);
|
|
127
|
+
r = n.lastIndex;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
var t = /[_\w][_\d\w]*/y;
|
|
131
|
+
|
|
132
|
+
function name() {
|
|
133
|
+
var e;
|
|
134
|
+
if (e = advance(t)) {
|
|
135
|
+
return {
|
|
136
|
+
kind: exports.Kind.NAME,
|
|
137
|
+
value: e
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
var o = /null/y;
|
|
143
|
+
|
|
144
|
+
var a = /true|false/y;
|
|
145
|
+
|
|
146
|
+
var s = /\$[_\w][_\d\w]*/y;
|
|
147
|
+
|
|
148
|
+
var d = /[-]?\d+/y;
|
|
149
|
+
|
|
150
|
+
var p = /(?:[-]?\d+)?(?:\.\d+)(?:[eE][+-]?\d+)?/y;
|
|
151
|
+
|
|
152
|
+
var u = /\\/g;
|
|
153
|
+
|
|
154
|
+
var v = /"""(?:[\s\S]+(?="""))?"""/y;
|
|
155
|
+
|
|
156
|
+
var l = /"(?:[^"\r\n]+)?"/y;
|
|
157
|
+
|
|
158
|
+
function value(i) {
|
|
159
|
+
var n;
|
|
160
|
+
var c;
|
|
161
|
+
if (advance(o)) {
|
|
162
|
+
n = {
|
|
163
|
+
kind: exports.Kind.NULL
|
|
164
|
+
};
|
|
165
|
+
} else if (c = advance(a)) {
|
|
166
|
+
n = {
|
|
167
|
+
kind: exports.Kind.BOOLEAN,
|
|
168
|
+
value: "true" === c
|
|
169
|
+
};
|
|
170
|
+
} else if (!i && (c = advance(s))) {
|
|
171
|
+
n = {
|
|
172
|
+
kind: exports.Kind.VARIABLE,
|
|
173
|
+
name: {
|
|
174
|
+
kind: exports.Kind.NAME,
|
|
175
|
+
value: c.slice(1)
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
} else if (c = advance(p)) {
|
|
179
|
+
n = {
|
|
180
|
+
kind: exports.Kind.FLOAT,
|
|
181
|
+
value: c
|
|
182
|
+
};
|
|
183
|
+
} else if (c = advance(d)) {
|
|
184
|
+
n = {
|
|
185
|
+
kind: exports.Kind.INT,
|
|
186
|
+
value: c
|
|
187
|
+
};
|
|
188
|
+
} else if (c = advance(t)) {
|
|
189
|
+
n = {
|
|
190
|
+
kind: exports.Kind.ENUM,
|
|
191
|
+
value: c
|
|
192
|
+
};
|
|
193
|
+
} else if (c = advance(v)) {
|
|
194
|
+
n = {
|
|
195
|
+
kind: exports.Kind.STRING,
|
|
196
|
+
value: blockString(c.slice(3, -3)),
|
|
197
|
+
block: !0
|
|
198
|
+
};
|
|
199
|
+
} else if (c = advance(l)) {
|
|
200
|
+
n = {
|
|
201
|
+
kind: exports.Kind.STRING,
|
|
202
|
+
value: u.test(c) ? JSON.parse(c) : c.slice(1, -1),
|
|
203
|
+
block: !1
|
|
204
|
+
};
|
|
205
|
+
} else if (n = function list(i) {
|
|
206
|
+
var n;
|
|
207
|
+
if (91 === e.charCodeAt(r)) {
|
|
208
|
+
r++;
|
|
209
|
+
ignored();
|
|
210
|
+
var t = [];
|
|
211
|
+
while (n = value(i)) {
|
|
212
|
+
t.push(n);
|
|
213
|
+
}
|
|
214
|
+
if (93 !== e.charCodeAt(r++)) {
|
|
215
|
+
throw error(exports.Kind.LIST);
|
|
216
|
+
}
|
|
217
|
+
ignored();
|
|
218
|
+
return {
|
|
219
|
+
kind: exports.Kind.LIST,
|
|
220
|
+
values: t
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}(i) || function object(i) {
|
|
224
|
+
if (123 === e.charCodeAt(r)) {
|
|
225
|
+
r++;
|
|
226
|
+
ignored();
|
|
227
|
+
var n = [];
|
|
228
|
+
var t;
|
|
229
|
+
while (t = name()) {
|
|
230
|
+
ignored();
|
|
231
|
+
if (58 !== e.charCodeAt(r++)) {
|
|
232
|
+
throw error(exports.Kind.OBJECT_FIELD);
|
|
233
|
+
}
|
|
234
|
+
ignored();
|
|
235
|
+
var o = value(i);
|
|
236
|
+
if (!o) {
|
|
237
|
+
throw error(exports.Kind.OBJECT_FIELD);
|
|
238
|
+
}
|
|
239
|
+
n.push({
|
|
240
|
+
kind: exports.Kind.OBJECT_FIELD,
|
|
241
|
+
name: t,
|
|
242
|
+
value: o
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
if (125 !== e.charCodeAt(r++)) {
|
|
246
|
+
throw error(exports.Kind.OBJECT);
|
|
247
|
+
}
|
|
248
|
+
ignored();
|
|
249
|
+
return {
|
|
250
|
+
kind: exports.Kind.OBJECT,
|
|
251
|
+
fields: n
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
}(i)) {
|
|
255
|
+
return n;
|
|
256
|
+
}
|
|
257
|
+
ignored();
|
|
258
|
+
return n;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function arguments_(i) {
|
|
262
|
+
var n = [];
|
|
263
|
+
ignored();
|
|
264
|
+
if (40 === e.charCodeAt(r)) {
|
|
265
|
+
r++;
|
|
266
|
+
ignored();
|
|
267
|
+
var t;
|
|
268
|
+
while (t = name()) {
|
|
269
|
+
ignored();
|
|
270
|
+
if (58 !== e.charCodeAt(r++)) {
|
|
271
|
+
throw error(exports.Kind.ARGUMENT);
|
|
272
|
+
}
|
|
273
|
+
ignored();
|
|
274
|
+
var o = value(i);
|
|
275
|
+
if (!o) {
|
|
276
|
+
throw error(exports.Kind.ARGUMENT);
|
|
277
|
+
}
|
|
278
|
+
n.push({
|
|
279
|
+
kind: exports.Kind.ARGUMENT,
|
|
280
|
+
name: t,
|
|
281
|
+
value: o
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
if (!n.length || 41 !== e.charCodeAt(r++)) {
|
|
285
|
+
throw error(exports.Kind.ARGUMENT);
|
|
286
|
+
}
|
|
287
|
+
ignored();
|
|
288
|
+
}
|
|
289
|
+
return n;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function directives(i) {
|
|
293
|
+
var n = [];
|
|
294
|
+
ignored();
|
|
295
|
+
while (64 === e.charCodeAt(r)) {
|
|
296
|
+
r++;
|
|
297
|
+
var t = name();
|
|
298
|
+
if (!t) {
|
|
299
|
+
throw error(exports.Kind.DIRECTIVE);
|
|
300
|
+
}
|
|
301
|
+
ignored();
|
|
302
|
+
n.push({
|
|
303
|
+
kind: exports.Kind.DIRECTIVE,
|
|
304
|
+
name: t,
|
|
305
|
+
arguments: arguments_(i)
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
return n;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function field() {
|
|
312
|
+
ignored();
|
|
313
|
+
var i = name();
|
|
314
|
+
if (i) {
|
|
315
|
+
ignored();
|
|
316
|
+
var n;
|
|
317
|
+
if (58 === e.charCodeAt(r)) {
|
|
318
|
+
r++;
|
|
319
|
+
ignored();
|
|
320
|
+
n = i;
|
|
321
|
+
if (!(i = name())) {
|
|
322
|
+
throw error(exports.Kind.FIELD);
|
|
323
|
+
}
|
|
324
|
+
ignored();
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
kind: exports.Kind.FIELD,
|
|
328
|
+
alias: n,
|
|
329
|
+
name: i,
|
|
330
|
+
arguments: arguments_(!1),
|
|
331
|
+
directives: directives(!1),
|
|
332
|
+
selectionSet: selectionSet()
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function type() {
|
|
338
|
+
var i;
|
|
339
|
+
ignored();
|
|
340
|
+
if (91 === e.charCodeAt(r)) {
|
|
341
|
+
r++;
|
|
342
|
+
ignored();
|
|
343
|
+
var n = type();
|
|
344
|
+
if (!n || 93 !== e.charCodeAt(r++)) {
|
|
345
|
+
throw error(exports.Kind.LIST_TYPE);
|
|
346
|
+
}
|
|
347
|
+
i = {
|
|
348
|
+
kind: exports.Kind.LIST_TYPE,
|
|
349
|
+
type: n
|
|
350
|
+
};
|
|
351
|
+
} else if (i = name()) {
|
|
352
|
+
i = {
|
|
353
|
+
kind: exports.Kind.NAMED_TYPE,
|
|
354
|
+
name: i
|
|
355
|
+
};
|
|
356
|
+
} else {
|
|
357
|
+
throw error(exports.Kind.NAMED_TYPE);
|
|
358
|
+
}
|
|
359
|
+
ignored();
|
|
360
|
+
if (33 === e.charCodeAt(r)) {
|
|
361
|
+
r++;
|
|
362
|
+
ignored();
|
|
363
|
+
return {
|
|
364
|
+
kind: exports.Kind.NON_NULL_TYPE,
|
|
365
|
+
type: i
|
|
366
|
+
};
|
|
367
|
+
} else {
|
|
368
|
+
return i;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
var c = /on/y;
|
|
373
|
+
|
|
374
|
+
function typeCondition() {
|
|
375
|
+
if (advance(c)) {
|
|
376
|
+
ignored();
|
|
377
|
+
var e = name();
|
|
378
|
+
if (!e) {
|
|
379
|
+
throw error(exports.Kind.NAMED_TYPE);
|
|
380
|
+
}
|
|
381
|
+
ignored();
|
|
382
|
+
return {
|
|
383
|
+
kind: exports.Kind.NAMED_TYPE,
|
|
384
|
+
name: e
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
var f = /\.\.\./y;
|
|
390
|
+
|
|
391
|
+
function fragmentSpread() {
|
|
392
|
+
ignored();
|
|
393
|
+
if (advance(f)) {
|
|
394
|
+
ignored();
|
|
395
|
+
var e = r;
|
|
396
|
+
var i;
|
|
397
|
+
if ((i = name()) && "on" !== i.value) {
|
|
398
|
+
return {
|
|
399
|
+
kind: exports.Kind.FRAGMENT_SPREAD,
|
|
400
|
+
name: i,
|
|
401
|
+
directives: directives(!1)
|
|
402
|
+
};
|
|
403
|
+
} else {
|
|
404
|
+
r = e;
|
|
405
|
+
var n = typeCondition();
|
|
406
|
+
var t = directives(!1);
|
|
407
|
+
var o = selectionSet();
|
|
408
|
+
if (!o) {
|
|
409
|
+
throw error(exports.Kind.INLINE_FRAGMENT);
|
|
410
|
+
}
|
|
411
|
+
return {
|
|
412
|
+
kind: exports.Kind.INLINE_FRAGMENT,
|
|
413
|
+
typeCondition: n,
|
|
414
|
+
directives: t,
|
|
415
|
+
selectionSet: o
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function selectionSet() {
|
|
422
|
+
var i;
|
|
423
|
+
ignored();
|
|
424
|
+
if (123 === e.charCodeAt(r)) {
|
|
425
|
+
r++;
|
|
426
|
+
ignored();
|
|
427
|
+
var n = [];
|
|
428
|
+
while (i = fragmentSpread() || field()) {
|
|
429
|
+
n.push(i);
|
|
430
|
+
}
|
|
431
|
+
if (!n.length || 125 !== e.charCodeAt(r++)) {
|
|
432
|
+
throw error(exports.Kind.SELECTION_SET);
|
|
433
|
+
}
|
|
434
|
+
ignored();
|
|
435
|
+
return {
|
|
436
|
+
kind: exports.Kind.SELECTION_SET,
|
|
437
|
+
selections: n
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
var E = /fragment/y;
|
|
443
|
+
|
|
444
|
+
function fragmentDefinition() {
|
|
445
|
+
if (advance(E)) {
|
|
446
|
+
ignored();
|
|
447
|
+
var e = name();
|
|
448
|
+
if (!e) {
|
|
449
|
+
throw error(exports.Kind.FRAGMENT_DEFINITION);
|
|
450
|
+
}
|
|
451
|
+
ignored();
|
|
452
|
+
var r = typeCondition();
|
|
453
|
+
if (!r) {
|
|
454
|
+
throw error(exports.Kind.FRAGMENT_DEFINITION);
|
|
455
|
+
}
|
|
456
|
+
var i = directives(!1);
|
|
457
|
+
var n = selectionSet();
|
|
458
|
+
if (!n) {
|
|
459
|
+
throw error(exports.Kind.FRAGMENT_DEFINITION);
|
|
460
|
+
}
|
|
461
|
+
return {
|
|
462
|
+
kind: exports.Kind.FRAGMENT_DEFINITION,
|
|
463
|
+
name: e,
|
|
464
|
+
typeCondition: r,
|
|
465
|
+
directives: i,
|
|
466
|
+
selectionSet: n
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
var N = /query|mutation|subscription/y;
|
|
472
|
+
|
|
473
|
+
function operationDefinition() {
|
|
474
|
+
var i;
|
|
475
|
+
var n;
|
|
476
|
+
var t = [];
|
|
477
|
+
var o = [];
|
|
478
|
+
if (i = advance(N)) {
|
|
479
|
+
ignored();
|
|
480
|
+
n = name();
|
|
481
|
+
t = function variableDefinitions() {
|
|
482
|
+
var i;
|
|
483
|
+
var n = [];
|
|
484
|
+
ignored();
|
|
485
|
+
if (40 === e.charCodeAt(r)) {
|
|
486
|
+
r++;
|
|
487
|
+
ignored();
|
|
488
|
+
while (i = advance(s)) {
|
|
489
|
+
ignored();
|
|
490
|
+
if (58 !== e.charCodeAt(r++)) {
|
|
491
|
+
throw error(exports.Kind.VARIABLE_DEFINITION);
|
|
492
|
+
}
|
|
493
|
+
var t = type();
|
|
494
|
+
if (!t) {
|
|
495
|
+
throw error(exports.Kind.VARIABLE_DEFINITION);
|
|
496
|
+
}
|
|
497
|
+
var o = void 0;
|
|
498
|
+
if (61 === e.charCodeAt(r)) {
|
|
499
|
+
r++;
|
|
500
|
+
ignored();
|
|
501
|
+
if (!(o = value(!0))) {
|
|
502
|
+
throw error(exports.Kind.VARIABLE_DEFINITION);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
ignored();
|
|
506
|
+
n.push({
|
|
507
|
+
kind: exports.Kind.VARIABLE_DEFINITION,
|
|
508
|
+
variable: {
|
|
509
|
+
kind: exports.Kind.VARIABLE,
|
|
510
|
+
name: {
|
|
511
|
+
kind: exports.Kind.NAME,
|
|
512
|
+
value: i.slice(1)
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
type: t,
|
|
516
|
+
defaultValue: o,
|
|
517
|
+
directives: directives(!0)
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
if (41 !== e.charCodeAt(r++)) {
|
|
521
|
+
throw error(exports.Kind.VARIABLE_DEFINITION);
|
|
522
|
+
}
|
|
523
|
+
ignored();
|
|
524
|
+
}
|
|
525
|
+
return n;
|
|
526
|
+
}();
|
|
527
|
+
o = directives(!1);
|
|
528
|
+
}
|
|
529
|
+
var a = selectionSet();
|
|
530
|
+
if (a) {
|
|
531
|
+
return {
|
|
532
|
+
kind: exports.Kind.OPERATION_DEFINITION,
|
|
533
|
+
operation: i || "query",
|
|
534
|
+
name: n,
|
|
535
|
+
variableDefinitions: t,
|
|
536
|
+
directives: o,
|
|
537
|
+
selectionSet: a
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
var I = {};
|
|
543
|
+
|
|
544
|
+
function printString(e) {
|
|
545
|
+
return JSON.stringify(e);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function printBlockString(e) {
|
|
549
|
+
return '"""\n' + e.replace(/"""/g, '\\"""') + '\n"""';
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
var hasItems = e => !(!e || !e.length);
|
|
553
|
+
|
|
554
|
+
var T = 80;
|
|
555
|
+
|
|
556
|
+
exports.BREAK = I;
|
|
557
|
+
|
|
558
|
+
exports.GraphQLError = GraphQLError;
|
|
559
|
+
|
|
560
|
+
exports.blockString = blockString;
|
|
561
|
+
|
|
562
|
+
exports.parse = function parse(i) {
|
|
563
|
+
e = i;
|
|
564
|
+
r = 0;
|
|
565
|
+
return function document() {
|
|
566
|
+
var i;
|
|
567
|
+
ignored();
|
|
568
|
+
var n = [];
|
|
569
|
+
while (i = fragmentDefinition() || operationDefinition()) {
|
|
570
|
+
n.push(i);
|
|
571
|
+
}
|
|
572
|
+
if (r !== e.length) {
|
|
573
|
+
throw error(exports.Kind.DOCUMENT);
|
|
574
|
+
}
|
|
575
|
+
return {
|
|
576
|
+
kind: exports.Kind.DOCUMENT,
|
|
577
|
+
definitions: n
|
|
578
|
+
};
|
|
579
|
+
}();
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
exports.parseType = function parseType(i) {
|
|
583
|
+
e = i;
|
|
584
|
+
r = 0;
|
|
585
|
+
return type();
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
exports.parseValue = function parseValue(i) {
|
|
589
|
+
e = i;
|
|
590
|
+
r = 0;
|
|
591
|
+
ignored();
|
|
592
|
+
return value(!1);
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
exports.print = function print(e) {
|
|
596
|
+
var r;
|
|
597
|
+
switch (e.kind) {
|
|
598
|
+
case exports.Kind.OPERATION_DEFINITION:
|
|
599
|
+
if ("query" === e.operation && !e.name && !hasItems(e.variableDefinitions) && !hasItems(e.directives)) {
|
|
600
|
+
return print(e.selectionSet);
|
|
601
|
+
}
|
|
602
|
+
r = e.operation;
|
|
603
|
+
if (e.name) {
|
|
604
|
+
r += " " + e.name.value;
|
|
605
|
+
}
|
|
606
|
+
if (hasItems(e.variableDefinitions)) {
|
|
607
|
+
if (!e.name) {
|
|
608
|
+
r += " ";
|
|
609
|
+
}
|
|
610
|
+
r += "(" + e.variableDefinitions.map(print).join(", ") + ")";
|
|
611
|
+
}
|
|
612
|
+
if (hasItems(e.directives)) {
|
|
613
|
+
r += " " + e.directives.map(print).join(" ");
|
|
614
|
+
}
|
|
615
|
+
return r + " " + print(e.selectionSet);
|
|
616
|
+
|
|
617
|
+
case exports.Kind.VARIABLE_DEFINITION:
|
|
618
|
+
r = print(e.variable) + ": " + print(e.type);
|
|
619
|
+
if (e.defaultValue) {
|
|
620
|
+
r += " = " + print(e.defaultValue);
|
|
621
|
+
}
|
|
622
|
+
if (hasItems(e.directives)) {
|
|
623
|
+
r += " " + e.directives.map(print).join(" ");
|
|
624
|
+
}
|
|
625
|
+
return r;
|
|
626
|
+
|
|
627
|
+
case exports.Kind.FIELD:
|
|
628
|
+
r = (e.alias ? print(e.alias) + ": " : "") + e.name.value;
|
|
629
|
+
if (hasItems(e.arguments)) {
|
|
630
|
+
var i = e.arguments.map(print);
|
|
631
|
+
var n = r + "(" + i.join(", ") + ")";
|
|
632
|
+
r = n.length > T ? r + "(\n " + i.join("\n").replace(/\n/g, "\n ") + "\n)" : n;
|
|
633
|
+
}
|
|
634
|
+
if (hasItems(e.directives)) {
|
|
635
|
+
r += " " + e.directives.map(print).join(" ");
|
|
636
|
+
}
|
|
637
|
+
return e.selectionSet ? r + " " + print(e.selectionSet) : r;
|
|
638
|
+
|
|
639
|
+
case exports.Kind.STRING:
|
|
640
|
+
return e.block ? printBlockString(e.value) : printString(e.value);
|
|
641
|
+
|
|
642
|
+
case exports.Kind.BOOLEAN:
|
|
643
|
+
return "" + e.value;
|
|
644
|
+
|
|
645
|
+
case exports.Kind.NULL:
|
|
646
|
+
return "null";
|
|
647
|
+
|
|
648
|
+
case exports.Kind.INT:
|
|
649
|
+
case exports.Kind.FLOAT:
|
|
650
|
+
case exports.Kind.ENUM:
|
|
651
|
+
case exports.Kind.NAME:
|
|
652
|
+
return e.value;
|
|
653
|
+
|
|
654
|
+
case exports.Kind.LIST:
|
|
655
|
+
return "[" + e.values.map(print).join(", ") + "]";
|
|
656
|
+
|
|
657
|
+
case exports.Kind.OBJECT:
|
|
658
|
+
return "{" + e.fields.map(print).join(", ") + "}";
|
|
659
|
+
|
|
660
|
+
case exports.Kind.OBJECT_FIELD:
|
|
661
|
+
return e.name.value + ": " + print(e.value);
|
|
662
|
+
|
|
663
|
+
case exports.Kind.VARIABLE:
|
|
664
|
+
return "$" + e.name.value;
|
|
665
|
+
|
|
666
|
+
case exports.Kind.DOCUMENT:
|
|
667
|
+
return hasItems(e.definitions) ? e.definitions.map(print).join("\n\n") : "";
|
|
668
|
+
|
|
669
|
+
case exports.Kind.SELECTION_SET:
|
|
670
|
+
return "{\n " + e.selections.map(print).join("\n").replace(/\n/g, "\n ") + "\n}";
|
|
671
|
+
|
|
672
|
+
case exports.Kind.ARGUMENT:
|
|
673
|
+
return e.name.value + ": " + print(e.value);
|
|
674
|
+
|
|
675
|
+
case exports.Kind.FRAGMENT_SPREAD:
|
|
676
|
+
r = "..." + e.name.value;
|
|
677
|
+
if (hasItems(e.directives)) {
|
|
678
|
+
r += " " + e.directives.map(print).join(" ");
|
|
679
|
+
}
|
|
680
|
+
return r;
|
|
681
|
+
|
|
682
|
+
case exports.Kind.INLINE_FRAGMENT:
|
|
683
|
+
r = "...";
|
|
684
|
+
if (e.typeCondition) {
|
|
685
|
+
r += " on " + e.typeCondition.name.value;
|
|
686
|
+
}
|
|
687
|
+
if (hasItems(e.directives)) {
|
|
688
|
+
r += " " + e.directives.map(print).join(" ");
|
|
689
|
+
}
|
|
690
|
+
return r + " " + print(e.selectionSet);
|
|
691
|
+
|
|
692
|
+
case exports.Kind.FRAGMENT_DEFINITION:
|
|
693
|
+
r = "fragment " + e.name.value;
|
|
694
|
+
r += " on " + e.typeCondition.name.value;
|
|
695
|
+
if (hasItems(e.directives)) {
|
|
696
|
+
r += " " + e.directives.map(print).join(" ");
|
|
697
|
+
}
|
|
698
|
+
return r + " " + print(e.selectionSet);
|
|
699
|
+
|
|
700
|
+
case exports.Kind.DIRECTIVE:
|
|
701
|
+
r = "@" + e.name.value;
|
|
702
|
+
if (hasItems(e.arguments)) {
|
|
703
|
+
r += "(" + e.arguments.map(print).join(", ") + ")";
|
|
704
|
+
}
|
|
705
|
+
return r;
|
|
706
|
+
|
|
707
|
+
case exports.Kind.NAMED_TYPE:
|
|
708
|
+
return e.name.value;
|
|
709
|
+
|
|
710
|
+
case exports.Kind.LIST_TYPE:
|
|
711
|
+
return "[" + print(e.type) + "]";
|
|
712
|
+
|
|
713
|
+
case exports.Kind.NON_NULL_TYPE:
|
|
714
|
+
return print(e.type) + "!";
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
exports.printBlockString = printBlockString;
|
|
719
|
+
|
|
720
|
+
exports.printString = printString;
|
|
721
|
+
|
|
722
|
+
exports.visit = function visit(e, r) {
|
|
723
|
+
var i = [];
|
|
724
|
+
var n = [];
|
|
725
|
+
try {
|
|
726
|
+
var t = function traverse(e, t, o) {
|
|
727
|
+
var a = !1;
|
|
728
|
+
var s = r[e.kind] && r[e.kind].enter || r[e.kind];
|
|
729
|
+
var d = s && s.call(r, e, t, o, n, i);
|
|
730
|
+
if (!1 === d) {
|
|
731
|
+
return e;
|
|
732
|
+
} else if (null === d) {
|
|
733
|
+
return null;
|
|
734
|
+
} else if (d === I) {
|
|
735
|
+
throw I;
|
|
736
|
+
} else if (d && "string" == typeof d.kind) {
|
|
737
|
+
a = d !== e;
|
|
738
|
+
e = d;
|
|
739
|
+
}
|
|
740
|
+
if (o) {
|
|
741
|
+
i.push(o);
|
|
742
|
+
}
|
|
743
|
+
var p;
|
|
744
|
+
var u = {
|
|
745
|
+
...e
|
|
746
|
+
};
|
|
747
|
+
for (var v in e) {
|
|
748
|
+
n.push(v);
|
|
749
|
+
var l = e[v];
|
|
750
|
+
if (Array.isArray(l)) {
|
|
751
|
+
var c = [];
|
|
752
|
+
for (var f = 0; f < l.length; f++) {
|
|
753
|
+
if (null != l[f] && "string" == typeof l[f].kind) {
|
|
754
|
+
i.push(e);
|
|
755
|
+
n.push(f);
|
|
756
|
+
p = traverse(l[f], f, l);
|
|
757
|
+
n.pop();
|
|
758
|
+
i.pop();
|
|
759
|
+
if (void 0 === p) {
|
|
760
|
+
c.push(l[f]);
|
|
761
|
+
} else if (null === p) {
|
|
762
|
+
a = !0;
|
|
763
|
+
} else {
|
|
764
|
+
a = a || p !== l[f];
|
|
765
|
+
c.push(p);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
l = c;
|
|
770
|
+
} else if (null != l && "string" == typeof l.kind) {
|
|
771
|
+
if (void 0 !== (p = traverse(l, v, e))) {
|
|
772
|
+
a = a || l !== p;
|
|
773
|
+
l = p;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
n.pop();
|
|
777
|
+
if (a) {
|
|
778
|
+
u[v] = l;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
if (o) {
|
|
782
|
+
i.pop();
|
|
783
|
+
}
|
|
784
|
+
var E = r[e.kind] && r[e.kind].leave;
|
|
785
|
+
var N = E && E.call(r, e, t, o, n, i);
|
|
786
|
+
if (N === I) {
|
|
787
|
+
throw I;
|
|
788
|
+
} else if (void 0 !== N) {
|
|
789
|
+
return N;
|
|
790
|
+
} else if (void 0 !== d) {
|
|
791
|
+
return a ? u : d;
|
|
792
|
+
} else {
|
|
793
|
+
return a ? u : e;
|
|
794
|
+
}
|
|
795
|
+
}(e);
|
|
796
|
+
return void 0 !== t && !1 !== t ? t : e;
|
|
797
|
+
} catch (r) {
|
|
798
|
+
if (r !== I) {
|
|
799
|
+
throw r;
|
|
800
|
+
}
|
|
801
|
+
return e;
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
//# sourceMappingURL=graphql.web.js.map
|