@xyd-js/gql 0.1.0-xyd.4 → 0.1.0-xyd.54

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +459 -0
  2. package/LICENSE +21 -0
  3. package/TODO.md +8 -0
  4. package/__fixtures__/-1.opendocs.docs-nested/input.graphql +66 -0
  5. package/__fixtures__/-1.opendocs.docs-nested/output.json +554 -0
  6. package/__fixtures__/-1.opendocs.flat/input.graphql +19 -0
  7. package/__fixtures__/-1.opendocs.flat/output.json +243 -0
  8. package/__fixtures__/-1.opendocs.scopes/input.graphql +33 -0
  9. package/__fixtures__/-1.opendocs.scopes/output.json +378 -0
  10. package/__fixtures__/-1.opendocs.sidebar/input.graphql +44 -0
  11. package/__fixtures__/-1.opendocs.sort/input.graphql +92 -0
  12. package/__fixtures__/-1.opendocs.sort/output.json +1078 -0
  13. package/__fixtures__/-1.opendocs.sort+group/input.graphql +111 -0
  14. package/__fixtures__/-1.opendocs.sort+group/output.json +1114 -0
  15. package/__fixtures__/-1.opendocs.sort+group+path/input.graphql +118 -0
  16. package/__fixtures__/-1.opendocs.sort+group+path/output.json +1114 -0
  17. package/__fixtures__/-2.complex.github/input.graphql +69424 -0
  18. package/__fixtures__/-2.complex.github/output.json +269874 -0
  19. package/__fixtures__/-2.complex.livesession/input.graphql +23 -0
  20. package/__fixtures__/-2.complex.livesession/output.json +302 -0
  21. package/__fixtures__/-2.complex.monday/input.graphql +6089 -0
  22. package/__fixtures__/-2.complex.monday/output.json +1 -0
  23. package/__fixtures__/-3.array-non-null-return/input.graphql +9 -0
  24. package/__fixtures__/-3.array-non-null-return/output.json +151 -0
  25. package/__fixtures__/1.basic/input.graphql +118 -0
  26. package/__fixtures__/1.basic/output.json +630 -0
  27. package/__fixtures__/2.circular/input.graphql +17 -0
  28. package/__fixtures__/2.circular/output.json +248 -0
  29. package/__fixtures__/3.opendocs/input.graphql +27 -0
  30. package/__fixtures__/3.opendocs/output.json +338 -0
  31. package/__fixtures__/4.union/input.graphql +19 -0
  32. package/__fixtures__/4.union/output.json +344 -0
  33. package/__fixtures__/5.flat/input.graphql +27 -0
  34. package/__fixtures__/5.flat/output.json +383 -0
  35. package/__fixtures__/6.default-values/input.graphql +47 -0
  36. package/__fixtures__/6.default-values/output.json +655 -0
  37. package/__fixtures__/7.type-args/input.graphql +19 -0
  38. package/__fixtures__/7.type-args/output.json +301 -0
  39. package/__fixtures__/8.default-sort/input.graphql +60 -0
  40. package/__fixtures__/8.default-sort/output.json +1078 -0
  41. package/__tests__/gqlSchemaToReferences.test.ts +109 -0
  42. package/__tests__/utils.ts +45 -0
  43. package/declarations.d.ts +4 -0
  44. package/dist/index.d.ts +17 -1
  45. package/dist/index.js +1334 -19871
  46. package/dist/index.js.map +1 -1
  47. package/dist/opendocs.graphql +56 -0
  48. package/package.json +7 -9
  49. package/src/context.ts +17 -0
  50. package/src/converters/gql-arg.ts +51 -0
  51. package/src/converters/gql-enum.ts +27 -0
  52. package/src/converters/gql-field.ts +164 -0
  53. package/src/converters/gql-input.ts +34 -0
  54. package/src/converters/gql-interface.ts +35 -0
  55. package/src/converters/gql-mutation.ts +36 -0
  56. package/src/converters/gql-object.ts +83 -0
  57. package/src/converters/gql-operation.ts +128 -0
  58. package/src/converters/gql-query.ts +36 -0
  59. package/src/converters/gql-sample.ts +159 -0
  60. package/src/converters/gql-scalar.ts +16 -0
  61. package/src/converters/gql-subscription.ts +36 -0
  62. package/src/converters/gql-types.ts +195 -0
  63. package/src/converters/gql-union.ts +40 -0
  64. package/src/gql-core.ts +362 -0
  65. package/src/opendocs.graphql +56 -0
  66. package/src/opendocs.ts +253 -0
  67. package/src/schema.ts +253 -67
  68. package/src/types.ts +103 -0
  69. package/src/utils.ts +21 -96
  70. package/tsconfig.json +1 -1
  71. package/tsup.config.ts +15 -1
  72. package/vitest.config.ts +15 -1
  73. package/examples/basic/index.ts +0 -12
  74. package/examples/basic/schema.graphqls +0 -89
  75. package/examples/basic/todo-app.graphqls +0 -184
  76. package/examples/graphql-types/graphql-types.0.basic.graphqls +0 -28
  77. package/examples/nested/nested-arg.0.not-required.graphqls +0 -8
  78. package/examples/nested/nested-arg.0.required.graphqls +0 -8
  79. package/examples/nested/nested-arg.1.deep.graphqls +0 -12
  80. package/src/hydration/README.md +0 -1
  81. package/src/hydration/gql-arg.ts +0 -53
  82. package/src/hydration/gql-field.ts +0 -206
  83. package/src/hydration/gql-input.ts +0 -67
  84. package/src/hydration/gql-object.ts +0 -35
  85. package/src/hydration/gql-types.ts +0 -50
  86. package/src/samples/index.ts +0 -95
  87. package/test/graphql-types.0.test.ts +0 -125
  88. package/test/nested-arg.0.test.ts +0 -208
  89. package/test/nested-arg.1.test.ts +0 -19
@@ -0,0 +1,630 @@
1
+ [
2
+ {
3
+ "title": "getBookByTitle",
4
+ "description": "Get a book by title",
5
+ "canonical": "queries/getBookByTitle",
6
+ "category": "graphql",
7
+ "type": "graphql_query",
8
+ "context": {
9
+ "graphqlTypeShort": "query",
10
+ "graphqlName": "getBookByTitle",
11
+ "group": [
12
+ "Queries"
13
+ ],
14
+ "scopes": []
15
+ },
16
+ "examples": {
17
+ "groups": [
18
+ {
19
+ "description": "",
20
+ "examples": [
21
+ {
22
+ "codeblock": {
23
+ "tabs": [
24
+ {
25
+ "title": "",
26
+ "language": "graphql",
27
+ "code": "{\n getBookByTitle(title: \"example-title\") {\n # getBookByTitle fields\n }\n}"
28
+ }
29
+ ]
30
+ }
31
+ }
32
+ ]
33
+ }
34
+ ]
35
+ },
36
+ "definitions": [
37
+ {
38
+ "title": "Arguments",
39
+ "properties": [
40
+ {
41
+ "name": "title",
42
+ "type": "String!",
43
+ "description": "The title of the book",
44
+ "context": {
45
+ "graphqlName": "title",
46
+ "graphqlTypeFlat": "String",
47
+ "graphqlBuiltInType": true
48
+ },
49
+ "properties": [],
50
+ "meta": [
51
+ {
52
+ "name": "required",
53
+ "value": "true"
54
+ }
55
+ ],
56
+ "symbolDef": {
57
+ "canonical": "/title"
58
+ }
59
+ },
60
+ {
61
+ "name": "info",
62
+ "type": "BookInfoInput",
63
+ "description": "The book info input",
64
+ "context": {
65
+ "graphqlTypeShort": "input",
66
+ "graphqlName": "BookInfoInput",
67
+ "group": [
68
+ "Inputs"
69
+ ],
70
+ "scopes": []
71
+ },
72
+ "properties": [],
73
+ "meta": [],
74
+ "symbolDef": {
75
+ "canonical": "inputs/BookInfoInput"
76
+ }
77
+ }
78
+ ]
79
+ },
80
+ {
81
+ "title": "Returns",
82
+ "properties": [
83
+ {
84
+ "name": "",
85
+ "type": "Book",
86
+ "description": "Get a book by title",
87
+ "context": {
88
+ "graphqlName": "getBookByTitle",
89
+ "graphqlTypeFlat": "Book",
90
+ "graphqlBuiltInType": false
91
+ },
92
+ "properties": [],
93
+ "meta": [],
94
+ "symbolDef": {
95
+ "canonical": "objects/Book"
96
+ }
97
+ }
98
+ ]
99
+ }
100
+ ]
101
+ },
102
+ {
103
+ "title": "addBook",
104
+ "description": "Add a book",
105
+ "canonical": "mutations/addBook",
106
+ "category": "graphql",
107
+ "type": "graphql_mutation",
108
+ "context": {
109
+ "graphqlTypeShort": "mutation",
110
+ "graphqlName": "addBook",
111
+ "group": [
112
+ "Mutations"
113
+ ],
114
+ "scopes": []
115
+ },
116
+ "examples": {
117
+ "groups": [
118
+ {
119
+ "description": "",
120
+ "examples": [
121
+ {
122
+ "codeblock": {
123
+ "tabs": [
124
+ {
125
+ "title": "",
126
+ "language": "graphql",
127
+ "code": "mutation addBook($input: BookInput!) {\n addBook(input: $input) {\n # addBook fields\n }\n}"
128
+ }
129
+ ]
130
+ }
131
+ }
132
+ ]
133
+ }
134
+ ]
135
+ },
136
+ "definitions": [
137
+ {
138
+ "title": "Arguments",
139
+ "properties": [
140
+ {
141
+ "name": "input",
142
+ "type": "BookInput!",
143
+ "description": "",
144
+ "context": {
145
+ "graphqlTypeShort": "input",
146
+ "graphqlName": "BookInput",
147
+ "group": [
148
+ "Inputs"
149
+ ],
150
+ "scopes": []
151
+ },
152
+ "properties": [],
153
+ "meta": [
154
+ {
155
+ "name": "required",
156
+ "value": "true"
157
+ }
158
+ ],
159
+ "symbolDef": {
160
+ "canonical": "inputs/BookInput"
161
+ }
162
+ }
163
+ ]
164
+ },
165
+ {
166
+ "title": "Returns",
167
+ "properties": [
168
+ {
169
+ "name": "",
170
+ "type": "Book!",
171
+ "description": "Add a book",
172
+ "context": {
173
+ "graphqlName": "addBook",
174
+ "graphqlTypeFlat": "Book",
175
+ "graphqlBuiltInType": false
176
+ },
177
+ "properties": [],
178
+ "meta": [
179
+ {
180
+ "name": "required",
181
+ "value": "true"
182
+ }
183
+ ],
184
+ "symbolDef": {
185
+ "canonical": "objects/Book"
186
+ }
187
+ }
188
+ ]
189
+ }
190
+ ]
191
+ },
192
+ {
193
+ "title": "addAuthor",
194
+ "description": "Add an author",
195
+ "canonical": "mutations/addAuthor",
196
+ "category": "graphql",
197
+ "type": "graphql_mutation",
198
+ "context": {
199
+ "graphqlTypeShort": "mutation",
200
+ "graphqlName": "addAuthor",
201
+ "group": [
202
+ "Mutations"
203
+ ],
204
+ "scopes": []
205
+ },
206
+ "examples": {
207
+ "groups": [
208
+ {
209
+ "description": "",
210
+ "examples": [
211
+ {
212
+ "codeblock": {
213
+ "tabs": [
214
+ {
215
+ "title": "",
216
+ "language": "graphql",
217
+ "code": "mutation addAuthor($name: String!) {\n addAuthor(name: $name) {\n # addAuthor fields\n }\n}"
218
+ }
219
+ ]
220
+ }
221
+ }
222
+ ]
223
+ }
224
+ ]
225
+ },
226
+ "definitions": [
227
+ {
228
+ "title": "Arguments",
229
+ "properties": [
230
+ {
231
+ "name": "name",
232
+ "type": "String!",
233
+ "description": "",
234
+ "context": {
235
+ "graphqlName": "name",
236
+ "graphqlTypeFlat": "String",
237
+ "graphqlBuiltInType": true
238
+ },
239
+ "properties": [],
240
+ "meta": [
241
+ {
242
+ "name": "required",
243
+ "value": "true"
244
+ }
245
+ ],
246
+ "symbolDef": {
247
+ "canonical": "/name"
248
+ }
249
+ }
250
+ ]
251
+ },
252
+ {
253
+ "title": "Returns",
254
+ "properties": [
255
+ {
256
+ "name": "",
257
+ "type": "Author!",
258
+ "description": "Add an author",
259
+ "context": {
260
+ "graphqlName": "addAuthor",
261
+ "graphqlTypeFlat": "Author",
262
+ "graphqlBuiltInType": false
263
+ },
264
+ "properties": [],
265
+ "meta": [
266
+ {
267
+ "name": "required",
268
+ "value": "true"
269
+ }
270
+ ],
271
+ "symbolDef": {
272
+ "canonical": "objects/Author"
273
+ }
274
+ }
275
+ ]
276
+ }
277
+ ]
278
+ },
279
+ {
280
+ "title": "Book",
281
+ "description": "A book type",
282
+ "canonical": "objects/Book",
283
+ "category": "graphql",
284
+ "type": "graphql_object",
285
+ "context": {
286
+ "graphqlTypeShort": "object",
287
+ "graphqlName": "Book",
288
+ "group": [
289
+ "Objects"
290
+ ],
291
+ "scopes": []
292
+ },
293
+ "examples": {
294
+ "groups": []
295
+ },
296
+ "definitions": [
297
+ {
298
+ "title": "Arguments",
299
+ "properties": [],
300
+ "variants": [],
301
+ "meta": [
302
+ {
303
+ "name": "type",
304
+ "value": "arguments"
305
+ }
306
+ ]
307
+ },
308
+ {
309
+ "title": "Fields",
310
+ "properties": [
311
+ {
312
+ "name": "title",
313
+ "type": "String!",
314
+ "description": "The title of the book",
315
+ "context": {
316
+ "graphqlName": "title",
317
+ "graphqlTypeFlat": "String",
318
+ "graphqlBuiltInType": true
319
+ },
320
+ "properties": [],
321
+ "meta": [
322
+ {
323
+ "name": "required",
324
+ "value": "true"
325
+ }
326
+ ],
327
+ "symbolDef": {
328
+ "canonical": "/title"
329
+ }
330
+ },
331
+ {
332
+ "name": "author_name",
333
+ "type": "String!",
334
+ "description": "The author of the book",
335
+ "context": {
336
+ "graphqlName": "author_name",
337
+ "graphqlTypeFlat": "String",
338
+ "graphqlBuiltInType": true
339
+ },
340
+ "properties": [],
341
+ "meta": [
342
+ {
343
+ "name": "required",
344
+ "value": "true"
345
+ }
346
+ ],
347
+ "symbolDef": {
348
+ "canonical": "/author_name"
349
+ }
350
+ },
351
+ {
352
+ "name": "info",
353
+ "type": "BookInfo!",
354
+ "description": "The nested book information",
355
+ "context": {
356
+ "graphqlName": "info",
357
+ "graphqlTypeFlat": "BookInfo",
358
+ "graphqlBuiltInType": false
359
+ },
360
+ "properties": [],
361
+ "meta": [
362
+ {
363
+ "name": "required",
364
+ "value": "true"
365
+ }
366
+ ],
367
+ "symbolDef": {
368
+ "canonical": "objects/BookInfo"
369
+ }
370
+ }
371
+ ],
372
+ "meta": [
373
+ {
374
+ "name": "type",
375
+ "value": "fields"
376
+ }
377
+ ]
378
+ }
379
+ ]
380
+ },
381
+ {
382
+ "title": "BookInfo",
383
+ "description": "A nested book information type",
384
+ "canonical": "objects/BookInfo",
385
+ "category": "graphql",
386
+ "type": "graphql_object",
387
+ "context": {
388
+ "graphqlTypeShort": "object",
389
+ "graphqlName": "BookInfo",
390
+ "group": [
391
+ "Objects"
392
+ ],
393
+ "scopes": []
394
+ },
395
+ "examples": {
396
+ "groups": []
397
+ },
398
+ "definitions": [
399
+ {
400
+ "title": "Arguments",
401
+ "properties": [],
402
+ "variants": [],
403
+ "meta": [
404
+ {
405
+ "name": "type",
406
+ "value": "arguments"
407
+ }
408
+ ]
409
+ },
410
+ {
411
+ "title": "Fields",
412
+ "properties": [
413
+ {
414
+ "name": "date",
415
+ "type": "String!",
416
+ "description": "The date of the book",
417
+ "context": {
418
+ "graphqlName": "date",
419
+ "graphqlTypeFlat": "String",
420
+ "graphqlBuiltInType": true
421
+ },
422
+ "properties": [],
423
+ "meta": [
424
+ {
425
+ "name": "required",
426
+ "value": "true"
427
+ }
428
+ ],
429
+ "symbolDef": {
430
+ "canonical": "/date"
431
+ }
432
+ }
433
+ ],
434
+ "meta": [
435
+ {
436
+ "name": "type",
437
+ "value": "fields"
438
+ }
439
+ ]
440
+ }
441
+ ]
442
+ },
443
+ {
444
+ "title": "Author",
445
+ "description": "An author type",
446
+ "canonical": "objects/Author",
447
+ "category": "graphql",
448
+ "type": "graphql_object",
449
+ "context": {
450
+ "graphqlTypeShort": "object",
451
+ "graphqlName": "Author",
452
+ "group": [
453
+ "Objects"
454
+ ],
455
+ "scopes": []
456
+ },
457
+ "examples": {
458
+ "groups": []
459
+ },
460
+ "definitions": [
461
+ {
462
+ "title": "Arguments",
463
+ "properties": [],
464
+ "variants": [],
465
+ "meta": [
466
+ {
467
+ "name": "type",
468
+ "value": "arguments"
469
+ }
470
+ ]
471
+ },
472
+ {
473
+ "title": "Fields",
474
+ "properties": [
475
+ {
476
+ "name": "name",
477
+ "type": "String!",
478
+ "description": "The name of the author",
479
+ "context": {
480
+ "graphqlName": "name",
481
+ "graphqlTypeFlat": "String",
482
+ "graphqlBuiltInType": true
483
+ },
484
+ "properties": [],
485
+ "meta": [
486
+ {
487
+ "name": "required",
488
+ "value": "true"
489
+ }
490
+ ],
491
+ "symbolDef": {
492
+ "canonical": "/name"
493
+ }
494
+ },
495
+ {
496
+ "name": "books",
497
+ "type": "[String]",
498
+ "description": "The books of the author",
499
+ "context": {
500
+ "graphqlName": "books",
501
+ "graphqlTypeFlat": "String",
502
+ "graphqlBuiltInType": true
503
+ },
504
+ "properties": [],
505
+ "meta": [],
506
+ "symbolDef": {
507
+ "canonical": "/books"
508
+ }
509
+ }
510
+ ],
511
+ "meta": [
512
+ {
513
+ "name": "type",
514
+ "value": "fields"
515
+ }
516
+ ]
517
+ }
518
+ ]
519
+ },
520
+ {
521
+ "title": "BookInput",
522
+ "description": "The input object for the getBook query",
523
+ "canonical": "inputs/BookInput",
524
+ "category": "graphql",
525
+ "type": "graphql_input",
526
+ "context": {
527
+ "graphqlTypeShort": "input",
528
+ "graphqlName": "BookInput",
529
+ "group": [
530
+ "Inputs"
531
+ ],
532
+ "scopes": []
533
+ },
534
+ "examples": {
535
+ "groups": []
536
+ },
537
+ "definitions": [
538
+ {
539
+ "title": "Fields",
540
+ "properties": [
541
+ {
542
+ "name": "title",
543
+ "type": "String!",
544
+ "description": "The title of the book",
545
+ "context": {
546
+ "graphqlName": "title",
547
+ "graphqlTypeFlat": "String",
548
+ "graphqlBuiltInType": true
549
+ },
550
+ "properties": [],
551
+ "meta": [
552
+ {
553
+ "name": "required",
554
+ "value": "true"
555
+ }
556
+ ],
557
+ "symbolDef": {
558
+ "canonical": "/title"
559
+ }
560
+ },
561
+ {
562
+ "name": "info",
563
+ "type": "BookInfoInput!",
564
+ "description": "The author of the book",
565
+ "context": {
566
+ "graphqlName": "info",
567
+ "graphqlTypeFlat": "BookInfoInput",
568
+ "graphqlBuiltInType": false
569
+ },
570
+ "properties": [],
571
+ "meta": [
572
+ {
573
+ "name": "required",
574
+ "value": "true"
575
+ }
576
+ ],
577
+ "symbolDef": {
578
+ "canonical": "inputs/BookInfoInput"
579
+ }
580
+ }
581
+ ]
582
+ }
583
+ ]
584
+ },
585
+ {
586
+ "title": "BookInfoInput",
587
+ "description": "A nested book information input",
588
+ "canonical": "inputs/BookInfoInput",
589
+ "category": "graphql",
590
+ "type": "graphql_input",
591
+ "context": {
592
+ "graphqlTypeShort": "input",
593
+ "graphqlName": "BookInfoInput",
594
+ "group": [
595
+ "Inputs"
596
+ ],
597
+ "scopes": []
598
+ },
599
+ "examples": {
600
+ "groups": []
601
+ },
602
+ "definitions": [
603
+ {
604
+ "title": "Fields",
605
+ "properties": [
606
+ {
607
+ "name": "date",
608
+ "type": "String!",
609
+ "description": "The date of the book",
610
+ "context": {
611
+ "graphqlName": "date",
612
+ "graphqlTypeFlat": "String",
613
+ "graphqlBuiltInType": true
614
+ },
615
+ "properties": [],
616
+ "meta": [
617
+ {
618
+ "name": "required",
619
+ "value": "true"
620
+ }
621
+ ],
622
+ "symbolDef": {
623
+ "canonical": "/date"
624
+ }
625
+ }
626
+ ]
627
+ }
628
+ ]
629
+ }
630
+ ]
@@ -0,0 +1,17 @@
1
+ type Author {
2
+ title: String!
3
+
4
+ books: [Book!]!
5
+ }
6
+
7
+ type Book {
8
+ title: String!
9
+
10
+ author: Author!
11
+ }
12
+
13
+ type Query {
14
+ getBookByTitle(
15
+ title: String!
16
+ ): Book
17
+ }