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