@gql.tada/cli-utils 1.7.4 → 1.8.1

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.
@@ -6,17 +6,14 @@ var r = require("@0no-co/graphqlsp/api");
6
6
 
7
7
  var n = require("./index-chunk2.js");
8
8
 
9
- var a = require("./index-chunk.js");
9
+ var t = require("./index-chunk.js");
10
10
 
11
- var t = "FragmentDefinition";
11
+ var a = "FragmentDefinition";
12
12
 
13
13
  class GraphQLError extends Error {
14
- constructor(e, i, r, n, a, t, o) {
15
- super(e);
16
- this.name = "GraphQLError";
17
- this.message = e;
18
- if (a) {
19
- this.path = a;
14
+ constructor(e, i, r, n, t, a, o) {
15
+ if (super(e), this.name = "GraphQLError", this.message = e, t) {
16
+ this.path = t;
20
17
  }
21
18
  if (i) {
22
19
  this.nodes = Array.isArray(i) ? i : [ i ];
@@ -27,17 +24,17 @@ class GraphQLError extends Error {
27
24
  if (n) {
28
25
  this.positions = n;
29
26
  }
30
- if (t) {
31
- this.originalError = t;
27
+ if (a) {
28
+ this.originalError = a;
32
29
  }
33
- var l = o;
34
- if (!l && t) {
35
- var s = t.extensions;
36
- if (s && "object" == typeof s) {
37
- l = s;
30
+ var s = o;
31
+ if (!s && a) {
32
+ var l = a.extensions;
33
+ if (l && "object" == typeof l) {
34
+ s = l;
38
35
  }
39
36
  }
40
- this.extensions = l || {};
37
+ this.extensions = s || {};
41
38
  }
42
39
  toJSON() {
43
40
  return {
@@ -55,564 +52,561 @@ class GraphQLError extends Error {
55
52
 
56
53
  var o;
57
54
 
58
- var l;
55
+ var s;
59
56
 
60
57
  function error(e) {
61
- return new GraphQLError(`Syntax Error: Unexpected token at ${l} in ${e}`);
58
+ return new GraphQLError(`Syntax Error: Unexpected token at ${s} in ${e}`);
62
59
  }
63
60
 
64
61
  function advance(e) {
65
- e.lastIndex = l;
66
- if (e.test(o)) {
67
- return o.slice(l, l = e.lastIndex);
62
+ if (e.lastIndex = s, e.test(o)) {
63
+ return o.slice(s, s = e.lastIndex);
68
64
  }
69
65
  }
70
66
 
71
- var s = / +(?=[^\s])/y;
67
+ var l = / +(?=[^\s])/y;
72
68
 
73
69
  function blockString(e) {
74
70
  var i = e.split("\n");
75
71
  var r = "";
76
72
  var n = 0;
77
- var a = 0;
78
- var t = i.length - 1;
73
+ var t = 0;
74
+ var a = i.length - 1;
79
75
  for (var o = 0; o < i.length; o++) {
80
- s.lastIndex = 0;
81
- if (s.test(i[o])) {
82
- if (o && (!n || s.lastIndex < n)) {
83
- n = s.lastIndex;
76
+ if (l.lastIndex = 0, l.test(i[o])) {
77
+ if (o && (!n || l.lastIndex < n)) {
78
+ n = l.lastIndex;
84
79
  }
85
- a = a || o;
86
- t = o;
80
+ t = t || o, a = o;
87
81
  }
88
82
  }
89
- for (var l = a; l <= t; l++) {
90
- if (l !== a) {
83
+ for (var s = t; s <= a; s++) {
84
+ if (s !== t) {
91
85
  r += "\n";
92
86
  }
93
- r += i[l].slice(n).replace(/\\"""/g, '"""');
87
+ r += i[s].slice(n).replace(/\\"""/g, '"""');
94
88
  }
95
89
  return r;
96
90
  }
97
91
 
98
92
  function ignored() {
99
- for (var e = 0 | o.charCodeAt(l++); 9 === e || 10 === e || 13 === e || 32 === e || 35 === e || 44 === e || 65279 === e; e = 0 | o.charCodeAt(l++)) {
93
+ for (var e = 0 | o.charCodeAt(s++); 9 === e || 10 === e || 13 === e || 32 === e || 35 === e || 44 === e || 65279 === e; e = 0 | o.charCodeAt(s++)) {
100
94
  if (35 === e) {
101
- while (10 !== (e = o.charCodeAt(l++)) && 13 !== e) {}
95
+ for (;(e = 0 | o.charCodeAt(s++)) && 10 !== e && 13 !== e; ) {}
102
96
  }
103
97
  }
104
- l--;
98
+ s--;
105
99
  }
106
100
 
107
- var u = /[_A-Za-z]\w*/y;
101
+ function name() {
102
+ var e = s;
103
+ for (var i = 0 | o.charCodeAt(s++); i >= 48 && i <= 57 || i >= 65 && i <= 90 || 95 === i || i >= 97 && i <= 122; i = 0 | o.charCodeAt(s++)) {}
104
+ if (e === s - 1) {
105
+ throw error("Name");
106
+ }
107
+ var r = o.slice(e, --s);
108
+ return ignored(), r;
109
+ }
108
110
 
109
- var d = new RegExp("(?:(null|true|false)|\\$(" + u.source + ')|(-?\\d+)((?:\\.\\d+)?[eE][+-]?\\d+|\\.\\d+)?|("""(?:"""|(?:[\\s\\S]*?[^\\\\])"""))|("(?:"|[^\\r\\n]*?[^\\\\]"))|(' + u.source + "))", "y");
111
+ function nameNode() {
112
+ return {
113
+ kind: "Name",
114
+ value: name()
115
+ };
116
+ }
110
117
 
111
- var c = function(e) {
112
- e[e.Const = 1] = "Const";
113
- e[e.Var = 2] = "Var";
114
- e[e.Int = 3] = "Int";
115
- e[e.Float = 4] = "Float";
116
- e[e.BlockString = 5] = "BlockString";
117
- e[e.String = 6] = "String";
118
- e[e.Enum = 7] = "Enum";
119
- return e;
120
- }(c || {});
118
+ var d = /(?:"""|(?:[\s\S]*?[^\\])""")/y;
121
119
 
122
- var v = /\\/g;
120
+ var c = /(?:(?:\.\d+)?[eE][+-]?\d+|\.\d+)/y;
123
121
 
124
122
  function value(e) {
125
123
  var i;
126
- var r;
127
- d.lastIndex = l;
128
- if (91 === o.charCodeAt(l)) {
129
- l++;
130
- ignored();
131
- var n = [];
132
- while (93 !== o.charCodeAt(l)) {
133
- n.push(value(e));
124
+ switch (o.charCodeAt(s)) {
125
+ case 91:
126
+ s++, ignored();
127
+ var r = [];
128
+ for (;93 !== o.charCodeAt(s); ) {
129
+ r.push(value(e));
134
130
  }
135
- l++;
136
- ignored();
137
- return {
131
+ return s++, ignored(), {
138
132
  kind: "ListValue",
139
- values: n
133
+ values: r
140
134
  };
141
- } else if (123 === o.charCodeAt(l)) {
142
- l++;
143
- ignored();
144
- var a = [];
145
- while (125 !== o.charCodeAt(l)) {
146
- if (null == (i = advance(u))) {
147
- throw error("ObjectField");
148
- }
149
- ignored();
150
- if (58 !== o.charCodeAt(l++)) {
135
+
136
+ case 123:
137
+ s++, ignored();
138
+ var n = [];
139
+ for (;125 !== o.charCodeAt(s); ) {
140
+ var t = nameNode();
141
+ if (58 !== o.charCodeAt(s++)) {
151
142
  throw error("ObjectField");
152
143
  }
153
- ignored();
154
- a.push({
144
+ ignored(), n.push({
155
145
  kind: "ObjectField",
156
- name: {
157
- kind: "Name",
158
- value: i
159
- },
146
+ name: t,
160
147
  value: value(e)
161
148
  });
162
149
  }
163
- l++;
164
- ignored();
165
- return {
150
+ return s++, ignored(), {
166
151
  kind: "ObjectValue",
167
- fields: a
152
+ fields: n
168
153
  };
169
- } else if (null != (r = d.exec(o))) {
170
- l = d.lastIndex;
171
- ignored();
172
- if (null != (i = r[c.Const])) {
173
- return "null" === i ? {
174
- kind: "NullValue"
175
- } : {
176
- kind: "BooleanValue",
177
- value: "true" === i
178
- };
179
- } else if (null != (i = r[c.Var])) {
180
- if (e) {
181
- throw error("Variable");
182
- } else {
183
- return {
184
- kind: "Variable",
185
- name: {
186
- kind: "Name",
187
- value: i
188
- }
189
- };
190
- }
191
- } else if (null != (i = r[c.Int])) {
192
- var t;
193
- if (null != (t = r[c.Float])) {
194
- return {
195
- kind: "FloatValue",
196
- value: i + t
197
- };
198
- } else {
199
- return {
200
- kind: "IntValue",
201
- value: i
202
- };
154
+
155
+ case 36:
156
+ if (e) {
157
+ throw error("Variable");
158
+ }
159
+ return s++, {
160
+ kind: "Variable",
161
+ name: nameNode()
162
+ };
163
+
164
+ case 34:
165
+ if (34 === o.charCodeAt(s + 1) && 34 === o.charCodeAt(s + 2)) {
166
+ if (s += 3, null == (i = advance(d))) {
167
+ throw error("StringValue");
203
168
  }
204
- } else if (null != (i = r[c.BlockString])) {
205
- return {
169
+ return ignored(), {
206
170
  kind: "StringValue",
207
- value: blockString(i.slice(3, -3)),
171
+ value: blockString(i.slice(0, -3)),
208
172
  block: !0
209
173
  };
210
- } else if (null != (i = r[c.String])) {
211
- return {
174
+ } else {
175
+ var a = s;
176
+ var l;
177
+ s++;
178
+ var u = !1;
179
+ for (l = 0 | o.charCodeAt(s++); 92 === l && (s++, u = !0) || 10 !== l && 13 !== l && 34 !== l && l; l = 0 | o.charCodeAt(s++)) {}
180
+ if (34 !== l) {
181
+ throw error("StringValue");
182
+ }
183
+ return i = o.slice(a, s), ignored(), {
212
184
  kind: "StringValue",
213
- value: v.test(i) ? JSON.parse(i) : i.slice(1, -1),
185
+ value: u ? JSON.parse(i) : i.slice(1, -1),
214
186
  block: !1
215
187
  };
216
- } else if (null != (i = r[c.Enum])) {
217
- return {
218
- kind: "EnumValue",
219
- value: i
188
+ }
189
+
190
+ case 45:
191
+ case 48:
192
+ case 49:
193
+ case 50:
194
+ case 51:
195
+ case 52:
196
+ case 53:
197
+ case 54:
198
+ case 55:
199
+ case 56:
200
+ case 57:
201
+ var v = s++;
202
+ var f;
203
+ for (;(f = 0 | o.charCodeAt(s++)) >= 48 && f <= 57; ) {}
204
+ var m = o.slice(v, --s);
205
+ if (46 === (f = o.charCodeAt(s)) || 69 === f || 101 === f) {
206
+ if (null == (i = advance(c))) {
207
+ throw error("FloatValue");
208
+ }
209
+ return ignored(), {
210
+ kind: "FloatValue",
211
+ value: m + i
212
+ };
213
+ } else {
214
+ return ignored(), {
215
+ kind: "IntValue",
216
+ value: m
217
+ };
218
+ }
219
+
220
+ case 110:
221
+ if (117 === o.charCodeAt(s + 1) && 108 === o.charCodeAt(s + 2) && 108 === o.charCodeAt(s + 3)) {
222
+ return s += 4, ignored(), {
223
+ kind: "NullValue"
224
+ };
225
+ } else {
226
+ break;
227
+ }
228
+
229
+ case 116:
230
+ if (114 === o.charCodeAt(s + 1) && 117 === o.charCodeAt(s + 2) && 101 === o.charCodeAt(s + 3)) {
231
+ return s += 4, ignored(), {
232
+ kind: "BooleanValue",
233
+ value: !0
234
+ };
235
+ } else {
236
+ break;
237
+ }
238
+
239
+ case 102:
240
+ if (97 === o.charCodeAt(s + 1) && 108 === o.charCodeAt(s + 2) && 115 === o.charCodeAt(s + 3) && 101 === o.charCodeAt(s + 4)) {
241
+ return s += 5, ignored(), {
242
+ kind: "BooleanValue",
243
+ value: !1
220
244
  };
245
+ } else {
246
+ break;
221
247
  }
222
248
  }
223
- throw error("Value");
249
+ return {
250
+ kind: "EnumValue",
251
+ value: name()
252
+ };
224
253
  }
225
254
 
226
255
  function arguments_(e) {
227
- if (40 === o.charCodeAt(l)) {
256
+ if (40 === o.charCodeAt(s)) {
228
257
  var i = [];
229
- l++;
230
- ignored();
231
- var r;
258
+ s++, ignored();
232
259
  do {
233
- if (null == (r = advance(u))) {
234
- throw error("Argument");
235
- }
236
- ignored();
237
- if (58 !== o.charCodeAt(l++)) {
260
+ var r = nameNode();
261
+ if (58 !== o.charCodeAt(s++)) {
238
262
  throw error("Argument");
239
263
  }
240
- ignored();
241
- i.push({
264
+ ignored(), i.push({
242
265
  kind: "Argument",
243
- name: {
244
- kind: "Name",
245
- value: r
246
- },
266
+ name: r,
247
267
  value: value(e)
248
268
  });
249
- } while (41 !== o.charCodeAt(l));
250
- l++;
251
- ignored();
252
- return i;
269
+ } while (41 !== o.charCodeAt(s));
270
+ return s++, ignored(), i;
253
271
  }
254
272
  }
255
273
 
256
274
  function directives(e) {
257
- if (64 === o.charCodeAt(l)) {
275
+ if (64 === o.charCodeAt(s)) {
258
276
  var i = [];
259
- var r;
260
277
  do {
261
- l++;
262
- if (null == (r = advance(u))) {
263
- throw error("Directive");
264
- }
265
- ignored();
266
- i.push({
278
+ s++, i.push({
267
279
  kind: "Directive",
268
- name: {
269
- kind: "Name",
270
- value: r
271
- },
280
+ name: nameNode(),
272
281
  arguments: arguments_(e)
273
282
  });
274
- } while (64 === o.charCodeAt(l));
283
+ } while (64 === o.charCodeAt(s));
275
284
  return i;
276
285
  }
277
286
  }
278
287
 
279
288
  function type() {
280
- var e;
281
- var i = 0;
282
- while (91 === o.charCodeAt(l)) {
283
- i++;
284
- l++;
285
- ignored();
289
+ var e = 0;
290
+ for (;91 === o.charCodeAt(s); ) {
291
+ e++, s++, ignored();
286
292
  }
287
- if (null == (e = advance(u))) {
288
- throw error("NamedType");
289
- }
290
- ignored();
291
- var r = {
293
+ var i = {
292
294
  kind: "NamedType",
293
- name: {
294
- kind: "Name",
295
- value: e
296
- }
295
+ name: nameNode()
297
296
  };
298
297
  do {
299
- if (33 === o.charCodeAt(l)) {
300
- l++;
301
- ignored();
302
- r = {
298
+ if (33 === o.charCodeAt(s)) {
299
+ s++, ignored(), i = {
303
300
  kind: "NonNullType",
304
- type: r
301
+ type: i
305
302
  };
306
303
  }
307
- if (i) {
308
- if (93 !== o.charCodeAt(l++)) {
304
+ if (e) {
305
+ if (93 !== o.charCodeAt(s++)) {
309
306
  throw error("NamedType");
310
307
  }
311
- ignored();
312
- r = {
308
+ ignored(), i = {
313
309
  kind: "ListType",
314
- type: r
310
+ type: i
315
311
  };
316
312
  }
317
- } while (i--);
318
- return r;
313
+ } while (e--);
314
+ return i;
319
315
  }
320
316
 
321
- var f = new RegExp("(?:(\\.{3})|(" + u.source + "))", "y");
322
-
323
- var g = function(e) {
324
- e[e.Spread = 1] = "Spread";
325
- e[e.Name = 2] = "Name";
326
- return e;
327
- }(g || {});
317
+ function selectionSetStart() {
318
+ if (123 !== o.charCodeAt(s++)) {
319
+ throw error("SelectionSet");
320
+ }
321
+ return ignored(), selectionSet();
322
+ }
328
323
 
329
324
  function selectionSet() {
330
325
  var e = [];
331
- var i;
332
- var r;
333
326
  do {
334
- f.lastIndex = l;
335
- if (null != (r = f.exec(o))) {
336
- l = f.lastIndex;
337
- if (null != r[g.Spread]) {
338
- ignored();
339
- var n = advance(u);
340
- if (null != n && "on" !== n) {
341
- ignored();
342
- e.push({
343
- kind: "FragmentSpread",
344
- name: {
345
- kind: "Name",
346
- value: n
327
+ if (46 === o.charCodeAt(s)) {
328
+ if (46 !== o.charCodeAt(++s) || 46 !== o.charCodeAt(++s)) {
329
+ throw error("SelectionSet");
330
+ }
331
+ switch (s++, ignored(), o.charCodeAt(s)) {
332
+ case 64:
333
+ e.push({
334
+ kind: "InlineFragment",
335
+ typeCondition: void 0,
336
+ directives: directives(!1),
337
+ selectionSet: selectionSetStart()
338
+ });
339
+ break;
340
+
341
+ case 111:
342
+ if (110 === o.charCodeAt(s + 1)) {
343
+ s += 2, ignored(), e.push({
344
+ kind: "InlineFragment",
345
+ typeCondition: {
346
+ kind: "NamedType",
347
+ name: nameNode()
347
348
  },
348
- directives: directives(!1)
349
+ directives: directives(!1),
350
+ selectionSet: selectionSetStart()
349
351
  });
350
352
  } else {
351
- ignored();
352
- if ("on" === n) {
353
- if (null == (n = advance(u))) {
354
- throw error("NamedType");
355
- }
356
- ignored();
357
- }
358
- var a = directives(!1);
359
- if (123 !== o.charCodeAt(l++)) {
360
- throw error("InlineFragment");
361
- }
362
- ignored();
363
353
  e.push({
364
- kind: "InlineFragment",
365
- typeCondition: n ? {
366
- kind: "NamedType",
367
- name: {
368
- kind: "Name",
369
- value: n
370
- }
371
- } : void 0,
372
- directives: a,
373
- selectionSet: selectionSet()
354
+ kind: "FragmentSpread",
355
+ name: nameNode(),
356
+ directives: directives(!1)
374
357
  });
375
358
  }
376
- } else if (null != (i = r[g.Name])) {
377
- var t = void 0;
378
- ignored();
379
- if (58 === o.charCodeAt(l)) {
380
- l++;
381
- ignored();
382
- t = i;
383
- if (null == (i = advance(u))) {
384
- throw error("Field");
385
- }
386
- ignored();
387
- }
388
- var s = arguments_(!1);
389
- ignored();
390
- var d = directives(!1);
391
- var c = void 0;
392
- if (123 === o.charCodeAt(l)) {
393
- l++;
394
- ignored();
395
- c = selectionSet();
396
- }
359
+ break;
360
+
361
+ case 123:
362
+ s++, ignored(), e.push({
363
+ kind: "InlineFragment",
364
+ typeCondition: void 0,
365
+ directives: void 0,
366
+ selectionSet: selectionSet()
367
+ });
368
+ break;
369
+
370
+ default:
397
371
  e.push({
398
- kind: "Field",
399
- alias: t ? {
400
- kind: "Name",
401
- value: t
402
- } : void 0,
403
- name: {
404
- kind: "Name",
405
- value: i
406
- },
407
- arguments: s,
408
- directives: d,
409
- selectionSet: c
372
+ kind: "FragmentSpread",
373
+ name: nameNode(),
374
+ directives: directives(!1)
410
375
  });
411
376
  }
412
377
  } else {
413
- throw error("SelectionSet");
378
+ var i = nameNode();
379
+ var r = void 0;
380
+ if (58 === o.charCodeAt(s)) {
381
+ s++, ignored(), r = i, i = nameNode();
382
+ }
383
+ var n = arguments_(!1);
384
+ var t = directives(!1);
385
+ var a = void 0;
386
+ if (123 === o.charCodeAt(s)) {
387
+ s++, ignored(), a = selectionSet();
388
+ }
389
+ e.push({
390
+ kind: "Field",
391
+ alias: r,
392
+ name: i,
393
+ arguments: n,
394
+ directives: t,
395
+ selectionSet: a
396
+ });
414
397
  }
415
- } while (125 !== o.charCodeAt(l));
416
- l++;
417
- ignored();
418
- return {
398
+ } while (125 !== o.charCodeAt(s));
399
+ return s++, ignored(), {
419
400
  kind: "SelectionSet",
420
401
  selections: e
421
402
  };
422
403
  }
423
404
 
424
- function fragmentDefinition() {
425
- var e;
426
- var i;
427
- if (null == (e = advance(u))) {
428
- throw error("FragmentDefinition");
429
- }
430
- ignored();
431
- if ("on" !== advance(u)) {
432
- throw error("FragmentDefinition");
433
- }
434
- ignored();
435
- if (null == (i = advance(u))) {
436
- throw error("FragmentDefinition");
405
+ function variableDefinitions() {
406
+ if (ignored(), 40 === o.charCodeAt(s)) {
407
+ var e = [];
408
+ s++, ignored();
409
+ do {
410
+ var i = void 0;
411
+ if (34 === o.charCodeAt(s)) {
412
+ i = value(!0);
413
+ }
414
+ if (36 !== o.charCodeAt(s++)) {
415
+ throw error("Variable");
416
+ }
417
+ var r = nameNode();
418
+ if (58 !== o.charCodeAt(s++)) {
419
+ throw error("VariableDefinition");
420
+ }
421
+ ignored();
422
+ var n = type();
423
+ var t = void 0;
424
+ if (61 === o.charCodeAt(s)) {
425
+ s++, ignored(), t = value(!0);
426
+ }
427
+ ignored();
428
+ var a = {
429
+ kind: "VariableDefinition",
430
+ variable: {
431
+ kind: "Variable",
432
+ name: r
433
+ },
434
+ type: n,
435
+ defaultValue: t,
436
+ directives: directives(!0)
437
+ };
438
+ if (i) {
439
+ a.description = i;
440
+ }
441
+ e.push(a);
442
+ } while (41 !== o.charCodeAt(s));
443
+ return s++, ignored(), e;
437
444
  }
438
- ignored();
439
- var r = directives(!1);
440
- if (123 !== o.charCodeAt(l++)) {
445
+ }
446
+
447
+ function fragmentDefinition(e) {
448
+ var i = nameNode();
449
+ if (111 !== o.charCodeAt(s++) || 110 !== o.charCodeAt(s++)) {
441
450
  throw error("FragmentDefinition");
442
451
  }
443
452
  ignored();
444
- return {
453
+ var r = {
445
454
  kind: "FragmentDefinition",
446
- name: {
447
- kind: "Name",
448
- value: e
449
- },
455
+ name: i,
450
456
  typeCondition: {
451
457
  kind: "NamedType",
452
- name: {
453
- kind: "Name",
454
- value: i
455
- }
458
+ name: nameNode()
456
459
  },
457
- directives: r,
458
- selectionSet: selectionSet()
460
+ directives: directives(!1),
461
+ selectionSet: selectionSetStart()
459
462
  };
463
+ if (e) {
464
+ r.description = e;
465
+ }
466
+ return r;
460
467
  }
461
468
 
462
- var m = /(?:query|mutation|subscription|fragment)/y;
469
+ function definitions() {
470
+ var e = [];
471
+ do {
472
+ var i = void 0;
473
+ if (34 === o.charCodeAt(s)) {
474
+ i = value(!0);
475
+ }
476
+ if (123 === o.charCodeAt(s)) {
477
+ if (i) {
478
+ throw error("Document");
479
+ }
480
+ s++, ignored(), e.push({
481
+ kind: "OperationDefinition",
482
+ operation: "query",
483
+ name: void 0,
484
+ variableDefinitions: void 0,
485
+ directives: void 0,
486
+ selectionSet: selectionSet()
487
+ });
488
+ } else {
489
+ var r = name();
490
+ switch (r) {
491
+ case "fragment":
492
+ e.push(fragmentDefinition(i));
493
+ break;
494
+
495
+ case "query":
496
+ case "mutation":
497
+ case "subscription":
498
+ var n;
499
+ var t = void 0;
500
+ if (40 !== (n = o.charCodeAt(s)) && 64 !== n && 123 !== n) {
501
+ t = nameNode();
502
+ }
503
+ var a = {
504
+ kind: "OperationDefinition",
505
+ operation: r,
506
+ name: t,
507
+ variableDefinitions: variableDefinitions(),
508
+ directives: directives(!1),
509
+ selectionSet: selectionSetStart()
510
+ };
511
+ if (i) {
512
+ a.description = i;
513
+ }
514
+ e.push(a);
515
+ break;
463
516
 
464
- function operationDefinition(e) {
465
- var i;
466
- var r;
467
- var n;
468
- if (e) {
469
- ignored();
470
- i = advance(u);
471
- r = function variableDefinitions() {
472
- ignored();
473
- if (40 === o.charCodeAt(l)) {
474
- var e = [];
475
- l++;
476
- ignored();
477
- var i;
478
- do {
479
- if (36 !== o.charCodeAt(l++)) {
480
- throw error("Variable");
481
- }
482
- if (null == (i = advance(u))) {
483
- throw error("Variable");
484
- }
485
- ignored();
486
- if (58 !== o.charCodeAt(l++)) {
487
- throw error("VariableDefinition");
488
- }
489
- ignored();
490
- var r = type();
491
- var n = void 0;
492
- if (61 === o.charCodeAt(l)) {
493
- l++;
494
- ignored();
495
- n = value(!0);
496
- }
497
- ignored();
498
- e.push({
499
- kind: "VariableDefinition",
500
- variable: {
501
- kind: "Variable",
502
- name: {
503
- kind: "Name",
504
- value: i
505
- }
506
- },
507
- type: r,
508
- defaultValue: n,
509
- directives: directives(!0)
510
- });
511
- } while (41 !== o.charCodeAt(l));
512
- l++;
513
- ignored();
514
- return e;
517
+ default:
518
+ throw error("Document");
515
519
  }
516
- }();
517
- n = directives(!1);
518
- }
519
- if (123 === o.charCodeAt(l)) {
520
- l++;
521
- ignored();
522
- return {
523
- kind: "OperationDefinition",
524
- operation: e || "query",
525
- name: i ? {
526
- kind: "Name",
527
- value: i
528
- } : void 0,
529
- variableDefinitions: r,
530
- directives: n,
531
- selectionSet: selectionSet()
532
- };
533
- }
520
+ }
521
+ } while (s < o.length);
522
+ return e;
534
523
  }
535
524
 
536
525
  function parse(e, i) {
537
- o = "string" == typeof e.body ? e.body : e;
538
- l = 0;
539
- return function document() {
540
- var e;
541
- var i;
542
- ignored();
543
- var r = [];
544
- do {
545
- if ("fragment" === (e = advance(m))) {
546
- ignored();
547
- r.push(fragmentDefinition());
548
- } else if (null != (i = operationDefinition(e))) {
549
- r.push(i);
550
- } else {
551
- throw error("Document");
552
- }
553
- } while (l < o.length);
526
+ if (o = e.body ? e.body : e, s = 0, ignored(), i) {} else {
554
527
  return {
555
528
  kind: "Document",
556
- definitions: r
529
+ definitions: definitions(),
530
+ loc: {
531
+ start: 0,
532
+ end: o.length,
533
+ startToken: void 0,
534
+ endToken: void 0,
535
+ source: {
536
+ body: o,
537
+ name: "graphql.web",
538
+ locationOffset: {
539
+ line: 1,
540
+ column: 1
541
+ }
542
+ }
543
+ }
557
544
  };
558
- }();
545
+ }
559
546
  }
560
547
 
561
548
  function mapJoin(e, i, r) {
562
549
  var n = "";
563
- for (var a = 0; a < e.length; a++) {
564
- if (a) {
550
+ for (var t = 0; t < e.length; t++) {
551
+ if (t) {
565
552
  n += i;
566
553
  }
567
- n += r(e[a]);
554
+ n += r(e[t]);
568
555
  }
569
556
  return n;
570
557
  }
571
558
 
572
- var h = "\n";
559
+ var u = "\n";
573
560
 
574
- var p = {
561
+ var v = {
575
562
  OperationDefinition(e) {
576
- var i = e.operation;
577
- if (e.name) {
563
+ var i = "";
564
+ if (e.description) {
565
+ i += v.StringValue(e.description) + "\n";
566
+ }
567
+ if (i += e.operation, e.name) {
578
568
  i += " " + e.name.value;
579
569
  }
580
570
  if (e.variableDefinitions && e.variableDefinitions.length) {
581
571
  if (!e.name) {
582
572
  i += " ";
583
573
  }
584
- i += "(" + mapJoin(e.variableDefinitions, ", ", p.VariableDefinition) + ")";
574
+ i += "(" + mapJoin(e.variableDefinitions, ", ", v.VariableDefinition) + ")";
585
575
  }
586
576
  if (e.directives && e.directives.length) {
587
- i += " " + mapJoin(e.directives, " ", p.Directive);
577
+ i += " " + mapJoin(e.directives, " ", v.Directive);
588
578
  }
589
- return "query" !== i ? i + " " + p.SelectionSet(e.selectionSet) : p.SelectionSet(e.selectionSet);
579
+ var r = v.SelectionSet(e.selectionSet);
580
+ return "query" !== i ? i + " " + r : r;
590
581
  },
591
582
  VariableDefinition(e) {
592
- var i = p.Variable(e.variable) + ": " + _print(e.type);
593
- if (e.defaultValue) {
583
+ var i = "";
584
+ if (e.description) {
585
+ i += v.StringValue(e.description) + " ";
586
+ }
587
+ if (i += v.Variable(e.variable) + ": " + _print(e.type), e.defaultValue) {
594
588
  i += " = " + _print(e.defaultValue);
595
589
  }
596
590
  if (e.directives && e.directives.length) {
597
- i += " " + mapJoin(e.directives, " ", p.Directive);
591
+ i += " " + mapJoin(e.directives, " ", v.Directive);
598
592
  }
599
593
  return i;
600
594
  },
601
595
  Field(e) {
602
596
  var i = e.alias ? e.alias.value + ": " + e.name.value : e.name.value;
603
597
  if (e.arguments && e.arguments.length) {
604
- var r = mapJoin(e.arguments, ", ", p.Argument);
598
+ var r = mapJoin(e.arguments, ", ", v.Argument);
605
599
  if (i.length + r.length + 2 > 80) {
606
- i += "(" + (h += " ") + mapJoin(e.arguments, h, p.Argument) + (h = h.slice(0, -2)) + ")";
600
+ i += "(" + (u += " ") + mapJoin(e.arguments, u, v.Argument) + (u = u.slice(0, -2)) + ")";
607
601
  } else {
608
602
  i += "(" + r + ")";
609
603
  }
610
604
  }
611
605
  if (e.directives && e.directives.length) {
612
- i += " " + mapJoin(e.directives, " ", p.Directive);
606
+ i += " " + mapJoin(e.directives, " ", v.Directive);
613
607
  }
614
- if (e.selectionSet) {
615
- i += " " + p.SelectionSet(e.selectionSet);
608
+ if (e.selectionSet && e.selectionSet.selections.length) {
609
+ i += " " + v.SelectionSet(e.selectionSet);
616
610
  }
617
611
  return i;
618
612
  },
@@ -620,7 +614,7 @@ var p = {
620
614
  if (e.block) {
621
615
  return function printBlockString(e) {
622
616
  return '"""\n' + e.replace(/"""/g, '\\"""') + '\n"""';
623
- }(e.value).replace(/\n/g, h);
617
+ }(e.value).replace(/\n/g, u);
624
618
  } else {
625
619
  return function printString(e) {
626
620
  return JSON.stringify(e);
@@ -635,20 +629,21 @@ var p = {
635
629
  Name: e => e.value,
636
630
  Variable: e => "$" + e.name.value,
637
631
  ListValue: e => "[" + mapJoin(e.values, ", ", _print) + "]",
638
- ObjectValue: e => "{" + mapJoin(e.fields, ", ", p.ObjectField) + "}",
632
+ ObjectValue: e => "{" + mapJoin(e.fields, ", ", v.ObjectField) + "}",
639
633
  ObjectField: e => e.name.value + ": " + _print(e.value),
640
634
  Document(e) {
641
635
  if (!e.definitions || !e.definitions.length) {
642
636
  return "";
637
+ } else {
638
+ return mapJoin(e.definitions, "\n\n", _print);
643
639
  }
644
- return mapJoin(e.definitions, "\n\n", _print);
645
640
  },
646
- SelectionSet: e => "{" + (h += " ") + mapJoin(e.selections, h, _print) + (h = h.slice(0, -2)) + "}",
641
+ SelectionSet: e => "{" + (u += " ") + mapJoin(e.selections, u, _print) + (u = u.slice(0, -2)) + "}",
647
642
  Argument: e => e.name.value + ": " + _print(e.value),
648
643
  FragmentSpread(e) {
649
644
  var i = "..." + e.name.value;
650
645
  if (e.directives && e.directives.length) {
651
- i += " " + mapJoin(e.directives, " ", p.Directive);
646
+ i += " " + mapJoin(e.directives, " ", v.Directive);
652
647
  }
653
648
  return i;
654
649
  },
@@ -658,22 +653,24 @@ var p = {
658
653
  i += " on " + e.typeCondition.name.value;
659
654
  }
660
655
  if (e.directives && e.directives.length) {
661
- i += " " + mapJoin(e.directives, " ", p.Directive);
656
+ i += " " + mapJoin(e.directives, " ", v.Directive);
662
657
  }
663
- return i + " " + p.SelectionSet(e.selectionSet);
658
+ return i + " " + v.SelectionSet(e.selectionSet);
664
659
  },
665
660
  FragmentDefinition(e) {
666
- var i = "fragment " + e.name.value;
667
- i += " on " + e.typeCondition.name.value;
668
- if (e.directives && e.directives.length) {
669
- i += " " + mapJoin(e.directives, " ", p.Directive);
661
+ var i = "";
662
+ if (e.description) {
663
+ i += v.StringValue(e.description) + "\n";
664
+ }
665
+ if (i += "fragment " + e.name.value, i += " on " + e.typeCondition.name.value, e.directives && e.directives.length) {
666
+ i += " " + mapJoin(e.directives, " ", v.Directive);
670
667
  }
671
- return i + " " + p.SelectionSet(e.selectionSet);
668
+ return i + " " + v.SelectionSet(e.selectionSet);
672
669
  },
673
670
  Directive(e) {
674
671
  var i = "@" + e.name.value;
675
672
  if (e.arguments && e.arguments.length) {
676
- i += "(" + mapJoin(e.arguments, ", ", p.Argument) + ")";
673
+ i += "(" + mapJoin(e.arguments, ", ", v.Argument) + ")";
677
674
  }
678
675
  return i;
679
676
  },
@@ -682,40 +679,39 @@ var p = {
682
679
  NonNullType: e => _print(e.type) + "!"
683
680
  };
684
681
 
685
- var _print = e => p[e.kind](e);
682
+ var _print = e => v[e.kind](e);
686
683
 
687
684
  function print(e) {
688
- h = "\n";
689
- return p[e.kind] ? p[e.kind](e) : "";
685
+ return u = "\n", v[e.kind] ? v[e.kind](e) : "";
690
686
  }
691
687
 
692
- var S = n.expose((async function* _runPersisted(n) {
688
+ var f = n.expose((async function* _runPersisted(n) {
693
689
  var o = i.getSchemaNamesFromConfig(n.pluginConfig);
694
- var l = a.programFactory(n);
695
- var s = l.createExternalFiles();
696
- if (s.length) {
690
+ var s = t.programFactory(n);
691
+ var l = s.createExternalFiles();
692
+ if (l.length) {
697
693
  yield {
698
694
  kind: "EXTERNAL_WARNING"
699
695
  };
700
- await l.addVirtualFiles(s);
696
+ await s.addVirtualFiles(l);
701
697
  }
702
- var u = l.build();
703
- var d = u.buildPluginInfo(n.pluginConfig);
704
- var c = u.getSourceFiles();
698
+ var d = s.build();
699
+ var c = d.buildPluginInfo(n.pluginConfig);
700
+ var u = d.getSourceFiles();
705
701
  yield {
706
702
  kind: "FILE_COUNT",
707
- fileCount: c.length
703
+ fileCount: u.length
708
704
  };
709
- for (var v of c) {
705
+ for (var v of u) {
710
706
  var f = v.fileName;
711
- var g = [];
712
707
  var m = [];
713
- var h = r.findAllPersistedCallExpressions(v, d);
714
- for (var p of h) {
715
- var S = u.getSourcePosition(v, p.node.getStart());
708
+ var h = [];
709
+ var g = r.findAllPersistedCallExpressions(v, c);
710
+ for (var p of g) {
711
+ var S = d.getSourcePosition(v, p.node.getStart());
716
712
  f = S.fileName;
717
713
  if (!o.has(p.schema)) {
718
- m.push({
714
+ h.push({
719
715
  message: p.schema ? `The '${p.schema}' schema is not in the configuration but was referenced by "graphql.persisted".` : o.size > 1 ? "The document is not for a known schema. Have you re-generated the output file?" : "Multiple schemas are configured, but the document is not for a specific schema.",
720
716
  file: S.fileName,
721
717
  line: S.line,
@@ -723,19 +719,19 @@ var S = n.expose((async function* _runPersisted(n) {
723
719
  });
724
720
  continue;
725
721
  }
726
- var k = p.node.arguments[0];
727
- var y = p.node.arguments[1];
728
- var N = p.node.typeArguments && p.node.typeArguments[0];
729
- if (!k || !e.isStringLiteral(k)) {
730
- m.push({
722
+ var C = p.node.arguments[0];
723
+ var A = p.node.arguments[1];
724
+ var k = p.node.typeArguments && p.node.typeArguments[0];
725
+ if (!C || !e.isStringLiteral(C)) {
726
+ h.push({
731
727
  message: '"graphql.persisted" must be called with a string literal as the first argument.',
732
728
  file: S.fileName,
733
729
  line: S.line,
734
730
  col: S.col
735
731
  });
736
732
  continue;
737
- } else if (!y && !N) {
738
- m.push({
733
+ } else if (!A && !k) {
734
+ h.push({
739
735
  message: '"graphql.persisted" is missing a document.\nThis may be passed as a generic such as `graphql.persisted<typeof document>` or as the second argument.',
740
736
  file: S.fileName,
741
737
  line: S.line,
@@ -743,55 +739,55 @@ var S = n.expose((async function* _runPersisted(n) {
743
739
  });
744
740
  continue;
745
741
  }
746
- var b = null;
747
- var C = p.node;
748
- if (y && (e.isCallExpression(y) || e.isIdentifier(y))) {
749
- b = r.getDocumentReferenceFromDocumentNode(y, v.fileName, d).node;
750
- C = y;
751
- } else if (N && e.isTypeQueryNode(N)) {
752
- b = r.getDocumentReferenceFromTypeQuery(N, v.fileName, d).node;
753
- C = N;
742
+ var y = null;
743
+ var b = p.node;
744
+ if (A && (e.isCallExpression(A) || e.isIdentifier(A))) {
745
+ y = r.getDocumentReferenceFromDocumentNode(A, v.fileName, c).node;
746
+ b = A;
747
+ } else if (k && e.isTypeQueryNode(k)) {
748
+ y = r.getDocumentReferenceFromTypeQuery(k, v.fileName, c).node;
749
+ b = k;
754
750
  }
755
- if (!b) {
756
- m.push({
757
- message: `Could not find reference for "${C.getText()}".\nIf this is unexpected, please file an issue describing your case.`,
751
+ if (!y) {
752
+ h.push({
753
+ message: `Could not find reference for "${b.getText()}".\nIf this is unexpected, please file an issue describing your case.`,
758
754
  file: S.fileName,
759
755
  line: S.line,
760
756
  col: S.col
761
757
  });
762
758
  continue;
763
759
  }
764
- if (!b || !e.isCallExpression(b) || !e.isNoSubstitutionTemplateLiteral(b.arguments[0]) && !e.isStringLiteral(b.arguments[0])) {
765
- m.push({
766
- message: `The referenced document of "${C.getText()}" contains no document string literal.\nIf this is unexpected, please file an issue describing your case.`,
760
+ if (!y || !e.isCallExpression(y) || !e.isNoSubstitutionTemplateLiteral(y.arguments[0]) && !e.isStringLiteral(y.arguments[0])) {
761
+ h.push({
762
+ message: `The referenced document of "${b.getText()}" contains no document string literal.\nIf this is unexpected, please file an issue describing your case.`,
767
763
  file: S.fileName,
768
764
  line: S.line,
769
765
  col: S.col
770
766
  });
771
767
  continue;
772
768
  }
773
- var A = [];
774
- var w = b.arguments[0].getText().slice(1, -1);
775
- if (b.arguments[1] && e.isArrayLiteralExpression(b.arguments[1])) {
776
- r.unrollTadaFragments(b.arguments[1], A, u.buildPluginInfo(n.pluginConfig));
769
+ var N = [];
770
+ var V = y.arguments[0].getText().slice(1, -1);
771
+ if (y.arguments[1] && e.isArrayLiteralExpression(y.arguments[1])) {
772
+ r.unrollTadaFragments(y.arguments[1], N, d.buildPluginInfo(n.pluginConfig));
777
773
  }
778
774
  var D = new Set;
779
- var V = void 0;
775
+ var w = void 0;
780
776
  if (n.disableNormalization) {
781
- V = w;
777
+ w = V;
782
778
  } else {
783
779
  try {
784
- var F = parse(w);
785
- var x = new Set;
786
- for (var T of F.definitions) {
787
- if (T.kind === t && !x.has(T)) {
788
- stripUnmaskDirectivesFromDefinition(T);
780
+ var F = parse(V);
781
+ var T = new Set;
782
+ for (var x of F.definitions) {
783
+ if (x.kind === a && !T.has(x)) {
784
+ stripUnmaskDirectivesFromDefinition(x);
789
785
  }
790
786
  }
791
- V = print(F);
787
+ w = print(F);
792
788
  } catch (e) {
793
- m.push({
794
- message: `The referenced document of "${C.getText()}" could not be parsed.\nRun \`check\` to see specific validation errors.`,
789
+ h.push({
790
+ message: `The referenced document of "${b.getText()}" could not be parsed.\nRun \`check\` to see specific validation errors.`,
795
791
  file: S.fileName,
796
792
  line: S.line,
797
793
  col: S.col
@@ -799,25 +795,25 @@ var S = n.expose((async function* _runPersisted(n) {
799
795
  continue;
800
796
  }
801
797
  }
802
- for (var E of A) {
798
+ for (var E of N) {
803
799
  stripUnmaskDirectivesFromDefinition(E);
804
800
  var I = print(E);
805
801
  if (!D.has(I)) {
806
- V += "\n\n" + print(E);
802
+ w += "\n\n" + print(E);
807
803
  D.add(I);
808
804
  }
809
805
  }
810
- g.push({
806
+ m.push({
811
807
  schemaName: p.schema,
812
- hashKey: k.getText().slice(1, -1),
813
- document: V
808
+ hashKey: C.getText().slice(1, -1),
809
+ document: w
814
810
  });
815
811
  }
816
812
  yield {
817
813
  kind: "FILE_PERSISTED",
818
814
  filePath: f,
819
- documents: g,
820
- warnings: m
815
+ documents: m,
816
+ warnings: h
821
817
  };
822
818
  }
823
819
  }));
@@ -826,5 +822,5 @@ var stripUnmaskDirectivesFromDefinition = e => {
826
822
  e.directives = e.directives?.filter((e => "_unmask" !== e.name.value));
827
823
  };
828
824
 
829
- exports.runPersisted = S;
825
+ exports.runPersisted = f;
830
826
  //# sourceMappingURL=thread-chunk.js.map