@0no-co/graphql.web 1.0.13 → 1.1.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.
@@ -3,30 +3,27 @@ Object.defineProperty(exports, "__esModule", {
3
3
  });
4
4
 
5
5
  class GraphQLError extends Error {
6
- constructor(e, r, n, i, t, a, o) {
7
- super(e);
8
- this.name = "GraphQLError";
9
- this.message = e;
10
- if (t) {
6
+ constructor(e, r, i, n, t, a, o) {
7
+ if (super(e), this.name = "GraphQLError", this.message = e, t) {
11
8
  this.path = t;
12
9
  }
13
10
  if (r) {
14
11
  this.nodes = Array.isArray(r) ? r : [ r ];
15
12
  }
16
- if (n) {
17
- this.source = n;
18
- }
19
13
  if (i) {
20
- this.positions = i;
14
+ this.source = i;
15
+ }
16
+ if (n) {
17
+ this.positions = n;
21
18
  }
22
19
  if (a) {
23
20
  this.originalError = a;
24
21
  }
25
22
  var l = o;
26
23
  if (!l && a) {
27
- var u = a.extensions;
28
- if (u && "object" == typeof u) {
29
- l = u;
24
+ var d = a.extensions;
25
+ if (d && "object" == typeof d) {
26
+ l = d;
30
27
  }
31
28
  }
32
29
  this.extensions = l || {};
@@ -53,489 +50,411 @@ function error(e) {
53
50
  return new GraphQLError(`Syntax Error: Unexpected token at ${r} in ${e}`);
54
51
  }
55
52
 
56
- function advance(n) {
57
- n.lastIndex = r;
58
- if (n.test(e)) {
59
- return e.slice(r, r = n.lastIndex);
53
+ function advance(i) {
54
+ if (i.lastIndex = r, i.test(e)) {
55
+ return e.slice(r, r = i.lastIndex);
60
56
  }
61
57
  }
62
58
 
63
- var n = / +(?=[^\s])/y;
59
+ var i = / +(?=[^\s])/y;
64
60
 
65
61
  function blockString(e) {
66
62
  var r = e.split("\n");
67
- var i = "";
63
+ var n = "";
68
64
  var t = 0;
69
65
  var a = 0;
70
66
  var o = r.length - 1;
71
67
  for (var l = 0; l < r.length; l++) {
72
- n.lastIndex = 0;
73
- if (n.test(r[l])) {
74
- if (l && (!t || n.lastIndex < t)) {
75
- t = n.lastIndex;
68
+ if (i.lastIndex = 0, i.test(r[l])) {
69
+ if (l && (!t || i.lastIndex < t)) {
70
+ t = i.lastIndex;
76
71
  }
77
- a = a || l;
78
- o = l;
72
+ a = a || l, o = l;
79
73
  }
80
74
  }
81
- for (var u = a; u <= o; u++) {
82
- if (u !== a) {
83
- i += "\n";
75
+ for (var d = a; d <= o; d++) {
76
+ if (d !== a) {
77
+ n += "\n";
84
78
  }
85
- i += r[u].slice(t).replace(/\\"""/g, '"""');
79
+ n += r[d].slice(t).replace(/\\"""/g, '"""');
86
80
  }
87
- return i;
81
+ return n;
88
82
  }
89
83
 
90
84
  function ignored() {
91
- for (var n = 0 | e.charCodeAt(r++); 9 === n || 10 === n || 13 === n || 32 === n || 35 === n || 44 === n || 65279 === n; n = 0 | e.charCodeAt(r++)) {
92
- if (35 === n) {
93
- while (10 !== (n = e.charCodeAt(r++)) && 13 !== n) {}
85
+ for (var i = 0 | e.charCodeAt(r++); 9 === i || 10 === i || 13 === i || 32 === i || 35 === i || 44 === i || 65279 === i; i = 0 | e.charCodeAt(r++)) {
86
+ if (35 === i) {
87
+ for (;10 !== (i = e.charCodeAt(r++)) && 13 !== i; ) {}
94
88
  }
95
89
  }
96
90
  r--;
97
91
  }
98
92
 
99
- var i = /[_A-Za-z]\w*/y;
100
-
101
- var t = new RegExp("(?:(null|true|false)|\\$(" + i.source + ')|(-?\\d+)((?:\\.\\d+)?[eE][+-]?\\d+|\\.\\d+)?|("""(?:"""|(?:[\\s\\S]*?[^\\\\])"""))|("(?:"|[^\\r\\n]*?[^\\\\]"))|(' + i.source + "))", "y");
102
-
103
- var a = function(e) {
104
- e[e.Const = 1] = "Const";
105
- e[e.Var = 2] = "Var";
106
- e[e.Int = 3] = "Int";
107
- e[e.Float = 4] = "Float";
108
- e[e.BlockString = 5] = "BlockString";
109
- e[e.String = 6] = "String";
110
- e[e.Enum = 7] = "Enum";
111
- return e;
112
- }(a || {});
113
-
114
- var o = /\\/;
115
-
116
- function value(n) {
117
- var l;
118
- var u;
119
- t.lastIndex = r;
120
- if (91 === e.charCodeAt(r)) {
121
- r++;
122
- ignored();
123
- var d = [];
124
- while (93 !== e.charCodeAt(r)) {
125
- d.push(value(n));
126
- }
127
- r++;
128
- ignored();
129
- return {
93
+ function name() {
94
+ var i = r;
95
+ for (var n = 0 | e.charCodeAt(r++); n >= 48 && n <= 57 || n >= 65 && n <= 90 || 95 === n || n >= 97 && n <= 122; n = 0 | e.charCodeAt(r++)) {}
96
+ if (i === r - 1) {
97
+ throw error("Name");
98
+ }
99
+ var t = e.slice(i, --r);
100
+ return ignored(), t;
101
+ }
102
+
103
+ function nameNode() {
104
+ return {
105
+ kind: "Name",
106
+ value: name()
107
+ };
108
+ }
109
+
110
+ var n = /(?:"""|(?:[\s\S]*?[^\\])""")/y;
111
+
112
+ var t = /(?:(?:\.\d+)?[eE][+-]?\d+|\.\d+)/y;
113
+
114
+ function value(i) {
115
+ var a;
116
+ switch (e.charCodeAt(r)) {
117
+ case 91:
118
+ r++, ignored();
119
+ var o = [];
120
+ for (;93 !== e.charCodeAt(r); ) {
121
+ o.push(value(i));
122
+ }
123
+ return r++, ignored(), {
130
124
  kind: "ListValue",
131
- values: d
125
+ values: o
132
126
  };
133
- } else if (123 === e.charCodeAt(r)) {
134
- r++;
135
- ignored();
136
- var s = [];
137
- while (125 !== e.charCodeAt(r)) {
138
- if (null == (l = advance(i))) {
139
- throw error("ObjectField");
140
- }
141
- ignored();
127
+
128
+ case 123:
129
+ r++, ignored();
130
+ var l = [];
131
+ for (;125 !== e.charCodeAt(r); ) {
132
+ var d = nameNode();
142
133
  if (58 !== e.charCodeAt(r++)) {
143
134
  throw error("ObjectField");
144
135
  }
145
- ignored();
146
- s.push({
136
+ ignored(), l.push({
147
137
  kind: "ObjectField",
148
- name: {
149
- kind: "Name",
150
- value: l
151
- },
152
- value: value(n)
138
+ name: d,
139
+ value: value(i)
153
140
  });
154
141
  }
155
- r++;
156
- ignored();
157
- return {
142
+ return r++, ignored(), {
158
143
  kind: "ObjectValue",
159
- fields: s
144
+ fields: l
160
145
  };
161
- } else if (null != (u = t.exec(e))) {
162
- r = t.lastIndex;
163
- ignored();
164
- if (null != (l = u[a.Const])) {
165
- return "null" === l ? {
166
- kind: "NullValue"
167
- } : {
168
- kind: "BooleanValue",
169
- value: "true" === l
170
- };
171
- } else if (null != (l = u[a.Var])) {
172
- if (n) {
173
- throw error("Variable");
174
- } else {
175
- return {
176
- kind: "Variable",
177
- name: {
178
- kind: "Name",
179
- value: l
180
- }
181
- };
182
- }
183
- } else if (null != (l = u[a.Int])) {
184
- var v;
185
- if (null != (v = u[a.Float])) {
186
- return {
187
- kind: "FloatValue",
188
- value: l + v
189
- };
190
- } else {
191
- return {
192
- kind: "IntValue",
193
- value: l
194
- };
146
+
147
+ case 36:
148
+ if (i) {
149
+ throw error("Variable");
150
+ }
151
+ return r++, {
152
+ kind: "Variable",
153
+ name: nameNode()
154
+ };
155
+
156
+ case 34:
157
+ if (34 === e.charCodeAt(r + 1) && 34 === e.charCodeAt(r + 2)) {
158
+ if (r += 3, null == (a = advance(n))) {
159
+ throw error("StringValue");
195
160
  }
196
- } else if (null != (l = u[a.BlockString])) {
197
- return {
161
+ return ignored(), {
198
162
  kind: "StringValue",
199
- value: blockString(l.slice(3, -3)),
163
+ value: blockString(a.slice(0, -3)),
200
164
  block: !0
201
165
  };
202
- } else if (null != (l = u[a.String])) {
203
- return {
166
+ } else {
167
+ var u = r;
168
+ var s;
169
+ r++;
170
+ var c = !1;
171
+ for (s = 0 | e.charCodeAt(r++); 92 === s && (r++, c = !0) || 10 !== s && 13 !== s && 34 !== s && s; s = 0 | e.charCodeAt(r++)) {}
172
+ if (34 !== s) {
173
+ throw error("StringValue");
174
+ }
175
+ return a = e.slice(u, r), ignored(), {
204
176
  kind: "StringValue",
205
- value: o.test(l) ? JSON.parse(l) : l.slice(1, -1),
177
+ value: c ? JSON.parse(a) : a.slice(1, -1),
206
178
  block: !1
207
179
  };
208
- } else if (null != (l = u[a.Enum])) {
209
- return {
210
- kind: "EnumValue",
211
- value: l
180
+ }
181
+
182
+ case 45:
183
+ case 48:
184
+ case 49:
185
+ case 50:
186
+ case 51:
187
+ case 52:
188
+ case 53:
189
+ case 54:
190
+ case 55:
191
+ case 56:
192
+ case 57:
193
+ var v = r++;
194
+ var f;
195
+ for (;(f = 0 | e.charCodeAt(r++)) >= 48 && f <= 57; ) {}
196
+ var p = e.slice(v, --r);
197
+ if (46 === (f = e.charCodeAt(r)) || 69 === f || 101 === f) {
198
+ if (null == (a = advance(t))) {
199
+ throw error("FloatValue");
200
+ }
201
+ return ignored(), {
202
+ kind: "FloatValue",
203
+ value: p + a
204
+ };
205
+ } else {
206
+ return ignored(), {
207
+ kind: "IntValue",
208
+ value: p
212
209
  };
213
210
  }
211
+
212
+ case 110:
213
+ if (117 === e.charCodeAt(r + 1) && 108 === e.charCodeAt(r + 2) && 108 === e.charCodeAt(r + 3)) {
214
+ return r += 4, ignored(), {
215
+ kind: "NullValue"
216
+ };
217
+ } else {
218
+ break;
219
+ }
220
+
221
+ case 116:
222
+ if (114 === e.charCodeAt(r + 1) && 117 === e.charCodeAt(r + 2) && 101 === e.charCodeAt(r + 3)) {
223
+ return r += 4, ignored(), {
224
+ kind: "BooleanValue",
225
+ value: !0
226
+ };
227
+ } else {
228
+ break;
229
+ }
230
+
231
+ case 102:
232
+ if (97 === e.charCodeAt(r + 1) && 108 === e.charCodeAt(r + 2) && 115 === e.charCodeAt(r + 3) && 101 === e.charCodeAt(r + 4)) {
233
+ return r += 5, ignored(), {
234
+ kind: "BooleanValue",
235
+ value: !1
236
+ };
237
+ } else {
238
+ break;
239
+ }
214
240
  }
215
- throw error("Value");
241
+ return {
242
+ kind: "EnumValue",
243
+ value: name()
244
+ };
216
245
  }
217
246
 
218
- function arguments_(n) {
247
+ function arguments_(i) {
219
248
  if (40 === e.charCodeAt(r)) {
220
- var t = [];
221
- r++;
222
- ignored();
223
- var a;
249
+ var n = [];
250
+ r++, ignored();
224
251
  do {
225
- if (null == (a = advance(i))) {
226
- throw error("Argument");
227
- }
228
- ignored();
252
+ var t = nameNode();
229
253
  if (58 !== e.charCodeAt(r++)) {
230
254
  throw error("Argument");
231
255
  }
232
- ignored();
233
- t.push({
256
+ ignored(), n.push({
234
257
  kind: "Argument",
235
- name: {
236
- kind: "Name",
237
- value: a
238
- },
239
- value: value(n)
258
+ name: t,
259
+ value: value(i)
240
260
  });
241
261
  } while (41 !== e.charCodeAt(r));
242
- r++;
243
- ignored();
244
- return t;
262
+ return r++, ignored(), n;
245
263
  }
246
264
  }
247
265
 
248
- function directives(n) {
266
+ function directives(i) {
249
267
  if (64 === e.charCodeAt(r)) {
250
- var t = [];
251
- var a;
268
+ var n = [];
252
269
  do {
253
- r++;
254
- if (null == (a = advance(i))) {
255
- throw error("Directive");
256
- }
257
- ignored();
258
- t.push({
270
+ r++, n.push({
259
271
  kind: "Directive",
260
- name: {
261
- kind: "Name",
262
- value: a
263
- },
264
- arguments: arguments_(n)
272
+ name: nameNode(),
273
+ arguments: arguments_(i)
265
274
  });
266
275
  } while (64 === e.charCodeAt(r));
267
- return t;
276
+ return n;
268
277
  }
269
278
  }
270
279
 
271
280
  function type() {
272
- var n;
273
- var t = 0;
274
- while (91 === e.charCodeAt(r)) {
275
- t++;
276
- r++;
277
- ignored();
278
- }
279
- if (null == (n = advance(i))) {
280
- throw error("NamedType");
281
+ var i = 0;
282
+ for (;91 === e.charCodeAt(r); ) {
283
+ i++, r++, ignored();
281
284
  }
282
- ignored();
283
- var a = {
285
+ var n = {
284
286
  kind: "NamedType",
285
- name: {
286
- kind: "Name",
287
- value: n
288
- }
287
+ name: nameNode()
289
288
  };
290
289
  do {
291
290
  if (33 === e.charCodeAt(r)) {
292
- r++;
293
- ignored();
294
- a = {
291
+ r++, ignored(), n = {
295
292
  kind: "NonNullType",
296
- type: a
293
+ type: n
297
294
  };
298
295
  }
299
- if (t) {
296
+ if (i) {
300
297
  if (93 !== e.charCodeAt(r++)) {
301
298
  throw error("NamedType");
302
299
  }
303
- ignored();
304
- a = {
300
+ ignored(), n = {
305
301
  kind: "ListType",
306
- type: a
302
+ type: n
307
303
  };
308
304
  }
309
- } while (t--);
310
- return a;
305
+ } while (i--);
306
+ return n;
311
307
  }
312
308
 
313
- var l = new RegExp("(?:(\\.{3})|(" + i.source + "))", "y");
314
-
315
- var u = function(e) {
316
- e[e.Spread = 1] = "Spread";
317
- e[e.Name = 2] = "Name";
318
- return e;
319
- }(u || {});
309
+ function selectionSetStart() {
310
+ if (123 !== e.charCodeAt(r++)) {
311
+ throw error("SelectionSet");
312
+ }
313
+ return ignored(), selectionSet();
314
+ }
320
315
 
321
316
  function selectionSet() {
322
- var n = [];
323
- var t;
324
- var a;
317
+ var i = [];
325
318
  do {
326
- l.lastIndex = r;
327
- if (null != (a = l.exec(e))) {
328
- r = l.lastIndex;
329
- if (null != a[u.Spread]) {
330
- ignored();
331
- var o = advance(i);
332
- if (null != o && "on" !== o) {
333
- ignored();
334
- n.push({
335
- kind: "FragmentSpread",
336
- name: {
337
- kind: "Name",
338
- value: o
319
+ if (46 === e.charCodeAt(r)) {
320
+ if (46 !== e.charCodeAt(++r) || 46 !== e.charCodeAt(++r)) {
321
+ throw error("SelectionSet");
322
+ }
323
+ switch (r++, ignored(), e.charCodeAt(r)) {
324
+ case 64:
325
+ i.push({
326
+ kind: "InlineFragment",
327
+ typeCondition: void 0,
328
+ directives: directives(!1),
329
+ selectionSet: selectionSetStart()
330
+ });
331
+ break;
332
+
333
+ case 111:
334
+ if (110 === e.charCodeAt(r + 1)) {
335
+ r += 2, ignored(), i.push({
336
+ kind: "InlineFragment",
337
+ typeCondition: {
338
+ kind: "NamedType",
339
+ name: nameNode()
339
340
  },
340
- directives: directives(!1)
341
+ directives: directives(!1),
342
+ selectionSet: selectionSetStart()
341
343
  });
342
344
  } else {
343
- ignored();
344
- if ("on" === o) {
345
- if (null == (o = advance(i))) {
346
- throw error("NamedType");
347
- }
348
- ignored();
349
- }
350
- var d = directives(!1);
351
- if (123 !== e.charCodeAt(r++)) {
352
- throw error("InlineFragment");
353
- }
354
- ignored();
355
- n.push({
356
- kind: "InlineFragment",
357
- typeCondition: o ? {
358
- kind: "NamedType",
359
- name: {
360
- kind: "Name",
361
- value: o
362
- }
363
- } : void 0,
364
- directives: d,
365
- selectionSet: selectionSet()
345
+ i.push({
346
+ kind: "FragmentSpread",
347
+ name: nameNode(),
348
+ directives: directives(!1)
366
349
  });
367
350
  }
368
- } else if (null != (t = a[u.Name])) {
369
- var s = void 0;
370
- ignored();
371
- if (58 === e.charCodeAt(r)) {
372
- r++;
373
- ignored();
374
- s = t;
375
- if (null == (t = advance(i))) {
376
- throw error("Field");
377
- }
378
- ignored();
379
- }
380
- var v = arguments_(!1);
381
- ignored();
382
- var c = directives(!1);
383
- var f = void 0;
384
- if (123 === e.charCodeAt(r)) {
385
- r++;
386
- ignored();
387
- f = selectionSet();
388
- }
389
- n.push({
390
- kind: "Field",
391
- alias: s ? {
392
- kind: "Name",
393
- value: s
394
- } : void 0,
395
- name: {
396
- kind: "Name",
397
- value: t
398
- },
399
- arguments: v,
400
- directives: c,
401
- selectionSet: f
351
+ break;
352
+
353
+ case 123:
354
+ r++, ignored(), i.push({
355
+ kind: "InlineFragment",
356
+ typeCondition: void 0,
357
+ directives: void 0,
358
+ selectionSet: selectionSet()
359
+ });
360
+ break;
361
+
362
+ default:
363
+ i.push({
364
+ kind: "FragmentSpread",
365
+ name: nameNode(),
366
+ directives: directives(!1)
402
367
  });
403
368
  }
404
369
  } else {
405
- throw error("SelectionSet");
370
+ var n = nameNode();
371
+ var t = void 0;
372
+ if (58 === e.charCodeAt(r)) {
373
+ r++, ignored(), t = n, n = nameNode();
374
+ }
375
+ var a = arguments_(!1);
376
+ var o = directives(!1);
377
+ var l = void 0;
378
+ if (123 === e.charCodeAt(r)) {
379
+ r++, ignored(), l = selectionSet();
380
+ }
381
+ i.push({
382
+ kind: "Field",
383
+ alias: t,
384
+ name: n,
385
+ arguments: a,
386
+ directives: o,
387
+ selectionSet: l
388
+ });
406
389
  }
407
390
  } while (125 !== e.charCodeAt(r));
408
- r++;
409
- ignored();
410
- return {
391
+ return r++, ignored(), {
411
392
  kind: "SelectionSet",
412
- selections: n
393
+ selections: i
413
394
  };
414
395
  }
415
396
 
416
- function fragmentDefinition() {
417
- var n;
418
- var t;
419
- if (null == (n = advance(i))) {
420
- throw error("FragmentDefinition");
421
- }
422
- ignored();
423
- if ("on" !== advance(i)) {
424
- throw error("FragmentDefinition");
425
- }
426
- ignored();
427
- if (null == (t = advance(i))) {
428
- throw error("FragmentDefinition");
397
+ function variableDefinitions() {
398
+ if (ignored(), 40 === e.charCodeAt(r)) {
399
+ var i = [];
400
+ r++, ignored();
401
+ do {
402
+ if (36 !== e.charCodeAt(r++)) {
403
+ throw error("Variable");
404
+ }
405
+ var n = nameNode();
406
+ if (58 !== e.charCodeAt(r++)) {
407
+ throw error("VariableDefinition");
408
+ }
409
+ ignored();
410
+ var t = type();
411
+ var a = void 0;
412
+ if (61 === e.charCodeAt(r)) {
413
+ r++, ignored(), a = value(!0);
414
+ }
415
+ ignored(), i.push({
416
+ kind: "VariableDefinition",
417
+ variable: {
418
+ kind: "Variable",
419
+ name: n
420
+ },
421
+ type: t,
422
+ defaultValue: a,
423
+ directives: directives(!0)
424
+ });
425
+ } while (41 !== e.charCodeAt(r));
426
+ return r++, ignored(), i;
429
427
  }
430
- ignored();
431
- var a = directives(!1);
432
- if (123 !== e.charCodeAt(r++)) {
428
+ }
429
+
430
+ function fragmentDefinition() {
431
+ var i = nameNode();
432
+ if (111 !== e.charCodeAt(r++) || 110 !== e.charCodeAt(r++)) {
433
433
  throw error("FragmentDefinition");
434
434
  }
435
- ignored();
436
- return {
435
+ return ignored(), {
437
436
  kind: "FragmentDefinition",
438
- name: {
439
- kind: "Name",
440
- value: n
441
- },
437
+ name: i,
442
438
  typeCondition: {
443
439
  kind: "NamedType",
444
- name: {
445
- kind: "Name",
446
- value: t
447
- }
440
+ name: nameNode()
448
441
  },
449
- directives: a,
450
- selectionSet: selectionSet()
442
+ directives: directives(!1),
443
+ selectionSet: selectionSetStart()
451
444
  };
452
445
  }
453
446
 
454
- var d = /(?:query|mutation|subscription|fragment)/y;
455
-
456
- function operationDefinition(n) {
457
- var t;
458
- var a;
459
- var o;
460
- if (n) {
461
- ignored();
462
- t = advance(i);
463
- a = function variableDefinitions() {
464
- ignored();
465
- if (40 === e.charCodeAt(r)) {
466
- var n = [];
467
- r++;
468
- ignored();
469
- var t;
470
- do {
471
- if (36 !== e.charCodeAt(r++)) {
472
- throw error("Variable");
473
- }
474
- if (null == (t = advance(i))) {
475
- throw error("Variable");
476
- }
477
- ignored();
478
- if (58 !== e.charCodeAt(r++)) {
479
- throw error("VariableDefinition");
480
- }
481
- ignored();
482
- var a = type();
483
- var o = void 0;
484
- if (61 === e.charCodeAt(r)) {
485
- r++;
486
- ignored();
487
- o = value(!0);
488
- }
489
- ignored();
490
- n.push({
491
- kind: "VariableDefinition",
492
- variable: {
493
- kind: "Variable",
494
- name: {
495
- kind: "Name",
496
- value: t
497
- }
498
- },
499
- type: a,
500
- defaultValue: o,
501
- directives: directives(!0)
502
- });
503
- } while (41 !== e.charCodeAt(r));
504
- r++;
505
- ignored();
506
- return n;
507
- }
508
- }();
509
- o = directives(!1);
510
- }
511
- if (123 === e.charCodeAt(r)) {
512
- r++;
513
- ignored();
514
- return {
515
- kind: "OperationDefinition",
516
- operation: n || "query",
517
- name: t ? {
518
- kind: "Name",
519
- value: t
520
- } : void 0,
521
- variableDefinitions: a,
522
- directives: o,
523
- selectionSet: selectionSet()
524
- };
525
- }
526
- }
527
-
528
- var s = {};
447
+ var a = {};
529
448
 
530
- function mapJoin(e, r, n) {
531
- var i = "";
449
+ function mapJoin(e, r, i) {
450
+ var n = "";
532
451
  for (var t = 0; t < e.length; t++) {
533
452
  if (t) {
534
- i += r;
453
+ n += r;
535
454
  }
536
- i += n(e[t]);
455
+ n += i(e[t]);
537
456
  }
538
- return i;
457
+ return n;
539
458
  }
540
459
 
541
460
  function printString(e) {
@@ -546,9 +465,9 @@ function printBlockString(e) {
546
465
  return '"""\n' + e.replace(/"""/g, '\\"""') + '\n"""';
547
466
  }
548
467
 
549
- var v = "\n";
468
+ var o = "\n";
550
469
 
551
- var c = {
470
+ var l = {
552
471
  OperationDefinition(e) {
553
472
  var r = e.operation;
554
473
  if (e.name) {
@@ -558,44 +477,44 @@ var c = {
558
477
  if (!e.name) {
559
478
  r += " ";
560
479
  }
561
- r += "(" + mapJoin(e.variableDefinitions, ", ", c.VariableDefinition) + ")";
480
+ r += "(" + mapJoin(e.variableDefinitions, ", ", l.VariableDefinition) + ")";
562
481
  }
563
482
  if (e.directives && e.directives.length) {
564
- r += " " + mapJoin(e.directives, " ", c.Directive);
483
+ r += " " + mapJoin(e.directives, " ", l.Directive);
565
484
  }
566
- return "query" !== r ? r + " " + c.SelectionSet(e.selectionSet) : c.SelectionSet(e.selectionSet);
485
+ return "query" !== r ? r + " " + l.SelectionSet(e.selectionSet) : l.SelectionSet(e.selectionSet);
567
486
  },
568
487
  VariableDefinition(e) {
569
- var r = c.Variable(e.variable) + ": " + _print(e.type);
488
+ var r = l.Variable(e.variable) + ": " + _print(e.type);
570
489
  if (e.defaultValue) {
571
490
  r += " = " + _print(e.defaultValue);
572
491
  }
573
492
  if (e.directives && e.directives.length) {
574
- r += " " + mapJoin(e.directives, " ", c.Directive);
493
+ r += " " + mapJoin(e.directives, " ", l.Directive);
575
494
  }
576
495
  return r;
577
496
  },
578
497
  Field(e) {
579
498
  var r = e.alias ? e.alias.value + ": " + e.name.value : e.name.value;
580
499
  if (e.arguments && e.arguments.length) {
581
- var n = mapJoin(e.arguments, ", ", c.Argument);
582
- if (r.length + n.length + 2 > 80) {
583
- r += "(" + (v += " ") + mapJoin(e.arguments, v, c.Argument) + (v = v.slice(0, -2)) + ")";
500
+ var i = mapJoin(e.arguments, ", ", l.Argument);
501
+ if (r.length + i.length + 2 > 80) {
502
+ r += "(" + (o += " ") + mapJoin(e.arguments, o, l.Argument) + (o = o.slice(0, -2)) + ")";
584
503
  } else {
585
- r += "(" + n + ")";
504
+ r += "(" + i + ")";
586
505
  }
587
506
  }
588
507
  if (e.directives && e.directives.length) {
589
- r += " " + mapJoin(e.directives, " ", c.Directive);
508
+ r += " " + mapJoin(e.directives, " ", l.Directive);
590
509
  }
591
510
  if (e.selectionSet && e.selectionSet.selections.length) {
592
- r += " " + c.SelectionSet(e.selectionSet);
511
+ r += " " + l.SelectionSet(e.selectionSet);
593
512
  }
594
513
  return r;
595
514
  },
596
515
  StringValue(e) {
597
516
  if (e.block) {
598
- return printBlockString(e.value).replace(/\n/g, v);
517
+ return printBlockString(e.value).replace(/\n/g, o);
599
518
  } else {
600
519
  return printString(e.value);
601
520
  }
@@ -608,20 +527,21 @@ var c = {
608
527
  Name: e => e.value,
609
528
  Variable: e => "$" + e.name.value,
610
529
  ListValue: e => "[" + mapJoin(e.values, ", ", _print) + "]",
611
- ObjectValue: e => "{" + mapJoin(e.fields, ", ", c.ObjectField) + "}",
530
+ ObjectValue: e => "{" + mapJoin(e.fields, ", ", l.ObjectField) + "}",
612
531
  ObjectField: e => e.name.value + ": " + _print(e.value),
613
532
  Document(e) {
614
533
  if (!e.definitions || !e.definitions.length) {
615
534
  return "";
535
+ } else {
536
+ return mapJoin(e.definitions, "\n\n", _print);
616
537
  }
617
- return mapJoin(e.definitions, "\n\n", _print);
618
538
  },
619
- SelectionSet: e => "{" + (v += " ") + mapJoin(e.selections, v, _print) + (v = v.slice(0, -2)) + "}",
539
+ SelectionSet: e => "{" + (o += " ") + mapJoin(e.selections, o, _print) + (o = o.slice(0, -2)) + "}",
620
540
  Argument: e => e.name.value + ": " + _print(e.value),
621
541
  FragmentSpread(e) {
622
542
  var r = "..." + e.name.value;
623
543
  if (e.directives && e.directives.length) {
624
- r += " " + mapJoin(e.directives, " ", c.Directive);
544
+ r += " " + mapJoin(e.directives, " ", l.Directive);
625
545
  }
626
546
  return r;
627
547
  },
@@ -631,22 +551,21 @@ var c = {
631
551
  r += " on " + e.typeCondition.name.value;
632
552
  }
633
553
  if (e.directives && e.directives.length) {
634
- r += " " + mapJoin(e.directives, " ", c.Directive);
554
+ r += " " + mapJoin(e.directives, " ", l.Directive);
635
555
  }
636
- return r += " " + c.SelectionSet(e.selectionSet);
556
+ return r += " " + l.SelectionSet(e.selectionSet);
637
557
  },
638
558
  FragmentDefinition(e) {
639
559
  var r = "fragment " + e.name.value;
640
- r += " on " + e.typeCondition.name.value;
641
- if (e.directives && e.directives.length) {
642
- r += " " + mapJoin(e.directives, " ", c.Directive);
560
+ if (r += " on " + e.typeCondition.name.value, e.directives && e.directives.length) {
561
+ r += " " + mapJoin(e.directives, " ", l.Directive);
643
562
  }
644
- return r + " " + c.SelectionSet(e.selectionSet);
563
+ return r + " " + l.SelectionSet(e.selectionSet);
645
564
  },
646
565
  Directive(e) {
647
566
  var r = "@" + e.name.value;
648
567
  if (e.arguments && e.arguments.length) {
649
- r += "(" + mapJoin(e.arguments, ", ", c.Argument) + ")";
568
+ r += "(" + mapJoin(e.arguments, ", ", l.Argument) + ")";
650
569
  }
651
570
  return r;
652
571
  },
@@ -655,7 +574,7 @@ var c = {
655
574
  NonNullType: e => _print(e.type) + "!"
656
575
  };
657
576
 
658
- var _print = e => c[e.kind](e);
577
+ var _print = e => l[e.kind](e);
659
578
 
660
579
  function valueFromASTUntyped(e, r) {
661
580
  switch (e.kind) {
@@ -674,17 +593,17 @@ function valueFromASTUntyped(e, r) {
674
593
  return e.value;
675
594
 
676
595
  case "ListValue":
677
- var n = [];
678
- for (var i = 0, t = e.values.length; i < t; i++) {
679
- n.push(valueFromASTUntyped(e.values[i], r));
596
+ var i = [];
597
+ for (var n = 0, t = e.values.length; n < t; n++) {
598
+ i.push(valueFromASTUntyped(e.values[n], r));
680
599
  }
681
- return n;
600
+ return i;
682
601
 
683
602
  case "ObjectValue":
684
603
  var a = Object.create(null);
685
604
  for (var o = 0, l = e.fields.length; o < l; o++) {
686
- var u = e.fields[o];
687
- a[u.name.value] = valueFromASTUntyped(u.value, r);
605
+ var d = e.fields[o];
606
+ a[d.name.value] = valueFromASTUntyped(d.value, r);
688
607
  }
689
608
  return a;
690
609
 
@@ -693,11 +612,7 @@ function valueFromASTUntyped(e, r) {
693
612
  }
694
613
  }
695
614
 
696
- exports.BREAK = s;
697
-
698
- exports.GraphQLError = GraphQLError;
699
-
700
- exports.Kind = {
615
+ exports.BREAK = a, exports.GraphQLError = GraphQLError, exports.Kind = {
701
616
  NAME: "Name",
702
617
  DOCUMENT: "Document",
703
618
  OPERATION_DEFINITION: "OperationDefinition",
@@ -722,57 +637,76 @@ exports.Kind = {
722
637
  NAMED_TYPE: "NamedType",
723
638
  LIST_TYPE: "ListType",
724
639
  NON_NULL_TYPE: "NonNullType"
725
- };
726
-
727
- exports.OperationTypeNode = {
640
+ }, exports.OperationTypeNode = {
728
641
  QUERY: "query",
729
642
  MUTATION: "mutation",
730
643
  SUBSCRIPTION: "subscription"
731
- };
732
-
733
- exports.Source = function Source(e, r, n) {
644
+ }, exports.Source = function Source(e, r, i) {
734
645
  return {
735
646
  body: e,
736
647
  name: r,
737
- locationOffset: n || {
648
+ locationOffset: i || {
738
649
  line: 1,
739
650
  column: 1
740
651
  }
741
652
  };
742
- };
743
-
744
- exports.isSelectionNode = function isSelectionNode(e) {
653
+ }, exports.isSelectionNode = function isSelectionNode(e) {
745
654
  return "Field" === e.kind || "FragmentSpread" === e.kind || "InlineFragment" === e.kind;
746
- };
747
-
748
- exports.parse = function parse(n, i) {
749
- r = 0;
750
- return function document(e, n) {
751
- var i;
752
- var t;
655
+ }, exports.parse = function parse(i, n) {
656
+ return r = 0, function document(e, i) {
753
657
  ignored();
754
- var a = [];
658
+ var n = [];
755
659
  do {
756
- if ("fragment" === (i = advance(d))) {
757
- ignored();
758
- a.push(fragmentDefinition());
759
- } else if (null != (t = operationDefinition(i))) {
760
- a.push(t);
660
+ if (123 === e.charCodeAt(r)) {
661
+ n.push({
662
+ kind: "OperationDefinition",
663
+ operation: "query",
664
+ name: void 0,
665
+ variableDefinitions: void 0,
666
+ directives: void 0,
667
+ selectionSet: selectionSetStart()
668
+ });
761
669
  } else {
762
- throw error("Document");
670
+ var t = name();
671
+ switch (t) {
672
+ case "fragment":
673
+ n.push(fragmentDefinition());
674
+ break;
675
+
676
+ case "query":
677
+ case "mutation":
678
+ case "subscription":
679
+ var a;
680
+ var o = void 0;
681
+ if (40 !== (a = e.charCodeAt(r)) && 64 !== a && 123 !== a) {
682
+ o = nameNode();
683
+ }
684
+ n.push({
685
+ kind: "OperationDefinition",
686
+ operation: t,
687
+ name: o,
688
+ variableDefinitions: variableDefinitions(),
689
+ directives: directives(!1),
690
+ selectionSet: selectionSetStart()
691
+ });
692
+ break;
693
+
694
+ default:
695
+ throw error("Document");
696
+ }
763
697
  }
764
698
  } while (r < e.length);
765
- if (!n) {
766
- var o;
699
+ if (!i) {
700
+ var l;
767
701
  return {
768
702
  kind: "Document",
769
- definitions: a,
703
+ definitions: n,
770
704
  set loc(e) {
771
- o = e;
705
+ l = e;
772
706
  },
773
707
  get loc() {
774
- if (!o) {
775
- o = {
708
+ if (!l) {
709
+ l = {
776
710
  start: 0,
777
711
  end: e.length,
778
712
  startToken: void 0,
@@ -787,60 +721,41 @@ exports.parse = function parse(n, i) {
787
721
  }
788
722
  };
789
723
  }
790
- return o;
724
+ return l;
791
725
  }
792
726
  };
793
727
  }
794
728
  return {
795
729
  kind: "Document",
796
- definitions: a
730
+ definitions: n
797
731
  };
798
- }(e = "string" == typeof n.body ? n.body : n, i && i.noLocation);
799
- };
800
-
801
- exports.parseType = function parseType(n, i) {
802
- e = "string" == typeof n.body ? n.body : n;
803
- r = 0;
804
- return type();
805
- };
806
-
807
- exports.parseValue = function parseValue(n, i) {
808
- e = "string" == typeof n.body ? n.body : n;
809
- r = 0;
810
- ignored();
811
- return value(!1);
812
- };
813
-
814
- exports.print = function print(e) {
815
- v = "\n";
816
- return c[e.kind] ? c[e.kind](e) : "";
817
- };
818
-
819
- exports.printBlockString = printBlockString;
820
-
821
- exports.printString = printString;
822
-
823
- exports.valueFromASTUntyped = valueFromASTUntyped;
824
-
825
- exports.valueFromTypeNode = function valueFromTypeNode(e, r, n) {
732
+ }(e = i.body ? i.body : i, n && n.noLocation);
733
+ }, exports.parseType = function parseType(i, n) {
734
+ return e = i.body ? i.body : i, r = 0, type();
735
+ }, exports.parseValue = function parseValue(i, n) {
736
+ return e = i.body ? i.body : i, r = 0, ignored(), value(!1);
737
+ }, exports.print = function print(e) {
738
+ return o = "\n", l[e.kind] ? l[e.kind](e) : "";
739
+ }, exports.printBlockString = printBlockString, exports.printString = printString,
740
+ exports.valueFromASTUntyped = valueFromASTUntyped, exports.valueFromTypeNode = function valueFromTypeNode(e, r, i) {
826
741
  if ("Variable" === e.kind) {
827
- return n ? valueFromTypeNode(n[e.name.value], r, n) : void 0;
742
+ return i ? valueFromTypeNode(i[e.name.value], r, i) : void 0;
828
743
  } else if ("NonNullType" === r.kind) {
829
- return "NullValue" !== e.kind ? valueFromTypeNode(e, r, n) : void 0;
744
+ return "NullValue" !== e.kind ? valueFromTypeNode(e, r, i) : void 0;
830
745
  } else if ("NullValue" === e.kind) {
831
746
  return null;
832
747
  } else if ("ListType" === r.kind) {
833
748
  if ("ListValue" === e.kind) {
834
- var i = [];
749
+ var n = [];
835
750
  for (var t = 0, a = e.values.length; t < a; t++) {
836
- var o = valueFromTypeNode(e.values[t], r.type, n);
751
+ var o = valueFromTypeNode(e.values[t], r.type, i);
837
752
  if (void 0 === o) {
838
753
  return;
839
754
  } else {
840
- i.push(o);
755
+ n.push(o);
841
756
  }
842
757
  }
843
- return i;
758
+ return n;
844
759
  }
845
760
  } else if ("NamedType" === r.kind) {
846
761
  switch (r.name.value) {
@@ -848,89 +763,78 @@ exports.valueFromTypeNode = function valueFromTypeNode(e, r, n) {
848
763
  case "Float":
849
764
  case "String":
850
765
  case "Bool":
851
- return r.name.value + "Value" === e.kind ? valueFromASTUntyped(e, n) : void 0;
766
+ return r.name.value + "Value" === e.kind ? valueFromASTUntyped(e, i) : void 0;
852
767
 
853
768
  default:
854
- return valueFromASTUntyped(e, n);
769
+ return valueFromASTUntyped(e, i);
855
770
  }
856
771
  }
857
- };
858
-
859
- exports.visit = function visit(e, r) {
860
- var n = [];
772
+ }, exports.visit = function visit(e, r) {
861
773
  var i = [];
774
+ var n = [];
862
775
  try {
863
- var t = function traverse(e, t, a) {
864
- var o = !1;
865
- var l = r[e.kind] && r[e.kind].enter || r[e.kind] || r.enter;
866
- var u = l && l.call(r, e, t, a, i, n);
776
+ var t = function traverse(e, t, o) {
777
+ var l = !1;
778
+ var d = r[e.kind] && r[e.kind].enter || r[e.kind] || r.enter;
779
+ var u = d && d.call(r, e, t, o, n, i);
867
780
  if (!1 === u) {
868
781
  return e;
869
782
  } else if (null === u) {
870
783
  return null;
871
- } else if (u === s) {
872
- throw s;
784
+ } else if (u === a) {
785
+ throw a;
873
786
  } else if (u && "string" == typeof u.kind) {
874
- o = u !== e;
875
- e = u;
787
+ l = u !== e, e = u;
876
788
  }
877
- if (a) {
878
- n.push(a);
789
+ if (o) {
790
+ i.push(o);
879
791
  }
880
- var d;
881
- var v = {
792
+ var s;
793
+ var c = {
882
794
  ...e
883
795
  };
884
- for (var c in e) {
885
- i.push(c);
886
- var f = e[c];
796
+ for (var v in e) {
797
+ n.push(v);
798
+ var f = e[v];
887
799
  if (Array.isArray(f)) {
888
800
  var p = [];
889
- for (var g = 0; g < f.length; g++) {
890
- if (null != f[g] && "string" == typeof f[g].kind) {
891
- n.push(e);
892
- i.push(g);
893
- d = traverse(f[g], g, f);
894
- i.pop();
895
- n.pop();
896
- if (null == d) {
897
- o = !0;
801
+ for (var m = 0; m < f.length; m++) {
802
+ if (null != f[m] && "string" == typeof f[m].kind) {
803
+ if (i.push(e), n.push(m), s = traverse(f[m], m, f), n.pop(), i.pop(), null == s) {
804
+ l = !0;
898
805
  } else {
899
- o = o || d !== f[g];
900
- p.push(d);
806
+ l = l || s !== f[m], p.push(s);
901
807
  }
902
808
  }
903
809
  }
904
810
  f = p;
905
811
  } else if (null != f && "string" == typeof f.kind) {
906
- if (void 0 !== (d = traverse(f, c, e))) {
907
- o = o || f !== d;
908
- f = d;
812
+ if (void 0 !== (s = traverse(f, v, e))) {
813
+ l = l || f !== s, f = s;
909
814
  }
910
815
  }
911
- i.pop();
912
- if (o) {
913
- v[c] = f;
816
+ if (n.pop(), l) {
817
+ c[v] = f;
914
818
  }
915
819
  }
916
- if (a) {
917
- n.pop();
820
+ if (o) {
821
+ i.pop();
918
822
  }
919
- var m = r[e.kind] && r[e.kind].leave || r.leave;
920
- var h = m && m.call(r, e, t, a, i, n);
921
- if (h === s) {
922
- throw s;
923
- } else if (void 0 !== h) {
924
- return h;
823
+ var h = r[e.kind] && r[e.kind].leave || r.leave;
824
+ var g = h && h.call(r, e, t, o, n, i);
825
+ if (g === a) {
826
+ throw a;
827
+ } else if (void 0 !== g) {
828
+ return g;
925
829
  } else if (void 0 !== u) {
926
- return o ? v : u;
830
+ return l ? c : u;
927
831
  } else {
928
- return o ? v : e;
832
+ return l ? c : e;
929
833
  }
930
834
  }(e);
931
835
  return void 0 !== t && !1 !== t ? t : e;
932
836
  } catch (r) {
933
- if (r !== s) {
837
+ if (r !== a) {
934
838
  throw r;
935
839
  }
936
840
  return e;