@xyd-js/gql 0.0.0-build

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 (76) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -0
  4. package/TODO.md +8 -0
  5. package/__fixtures__/-1.opendocs.docs-nested/input.graphql +66 -0
  6. package/__fixtures__/-1.opendocs.docs-nested/output.json +554 -0
  7. package/__fixtures__/-1.opendocs.flat/input.graphql +19 -0
  8. package/__fixtures__/-1.opendocs.flat/output.json +243 -0
  9. package/__fixtures__/-1.opendocs.scopes/input.graphql +33 -0
  10. package/__fixtures__/-1.opendocs.scopes/output.json +378 -0
  11. package/__fixtures__/-1.opendocs.sidebar/input.graphql +44 -0
  12. package/__fixtures__/-1.opendocs.sort/input.graphql +92 -0
  13. package/__fixtures__/-1.opendocs.sort/output.json +1078 -0
  14. package/__fixtures__/-1.opendocs.sort+group/input.graphql +111 -0
  15. package/__fixtures__/-1.opendocs.sort+group/output.json +1114 -0
  16. package/__fixtures__/-1.opendocs.sort+group+path/input.graphql +118 -0
  17. package/__fixtures__/-1.opendocs.sort+group+path/output.json +1114 -0
  18. package/__fixtures__/-2.complex.github/input.graphql +69424 -0
  19. package/__fixtures__/-2.complex.github/output.json +269874 -0
  20. package/__fixtures__/-2.complex.livesession/input.graphql +23 -0
  21. package/__fixtures__/-2.complex.livesession/output.json +302 -0
  22. package/__fixtures__/-2.complex.monday/input.graphql +6089 -0
  23. package/__fixtures__/-2.complex.monday/output.json +1 -0
  24. package/__fixtures__/-3.array-non-null-return/input.graphql +9 -0
  25. package/__fixtures__/-3.array-non-null-return/output.json +151 -0
  26. package/__fixtures__/1.basic/input.graphql +118 -0
  27. package/__fixtures__/1.basic/output.json +630 -0
  28. package/__fixtures__/2.circular/input.graphql +17 -0
  29. package/__fixtures__/2.circular/output.json +248 -0
  30. package/__fixtures__/3.opendocs/input.graphql +27 -0
  31. package/__fixtures__/3.opendocs/output.json +338 -0
  32. package/__fixtures__/4.union/input.graphql +19 -0
  33. package/__fixtures__/4.union/output.json +344 -0
  34. package/__fixtures__/5.flat/input.graphql +27 -0
  35. package/__fixtures__/5.flat/output.json +383 -0
  36. package/__fixtures__/6.default-values/input.graphql +47 -0
  37. package/__fixtures__/6.default-values/output.json +655 -0
  38. package/__fixtures__/7.type-args/input.graphql +19 -0
  39. package/__fixtures__/7.type-args/output.json +301 -0
  40. package/__fixtures__/8.default-sort/input.graphql +60 -0
  41. package/__fixtures__/8.default-sort/output.json +1078 -0
  42. package/__tests__/gqlSchemaToReferences.test.ts +109 -0
  43. package/__tests__/utils.ts +45 -0
  44. package/declarations.d.ts +4 -0
  45. package/dist/index.d.ts +21 -0
  46. package/dist/index.js +1503 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/opendocs.graphql +56 -0
  49. package/index.ts +3 -0
  50. package/package.json +29 -0
  51. package/src/context.ts +17 -0
  52. package/src/converters/gql-arg.ts +51 -0
  53. package/src/converters/gql-enum.ts +27 -0
  54. package/src/converters/gql-field.ts +164 -0
  55. package/src/converters/gql-input.ts +34 -0
  56. package/src/converters/gql-interface.ts +35 -0
  57. package/src/converters/gql-mutation.ts +36 -0
  58. package/src/converters/gql-object.ts +83 -0
  59. package/src/converters/gql-operation.ts +128 -0
  60. package/src/converters/gql-query.ts +36 -0
  61. package/src/converters/gql-sample.ts +159 -0
  62. package/src/converters/gql-scalar.ts +16 -0
  63. package/src/converters/gql-subscription.ts +36 -0
  64. package/src/converters/gql-types.ts +195 -0
  65. package/src/converters/gql-union.ts +40 -0
  66. package/src/gql-core.ts +362 -0
  67. package/src/index.ts +3 -0
  68. package/src/opendocs.graphql +56 -0
  69. package/src/opendocs.ts +253 -0
  70. package/src/schema.ts +293 -0
  71. package/src/types.ts +103 -0
  72. package/src/utils.ts +25 -0
  73. package/tsconfig.json +18 -0
  74. package/tsup.config.ts +33 -0
  75. package/tsup.examples-config.ts +30 -0
  76. package/vitest.config.ts +21 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # @xyd-js/gql
2
+
3
+ ## 0.0.0-build+6952c2c-20250813013245
4
+
5
+ ### Patch Changes
6
+
7
+ - update all packages
8
+ - Updated dependencies
9
+ - @xyd-js/core@0.0.0-build+6952c2c-20250813013245
10
+ - @xyd-js/uniform@0.0.0-build+6952c2c-20250813013245
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 xyd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @xyd-js/gql
2
+
3
+ Transform GraphQL into xyd markdown interface.
package/TODO.md ADDED
@@ -0,0 +1,8 @@
1
+ 1. support nested inline default values if possible?
2
+ ```graphql
3
+ type Mutation {
4
+ setData(input: DataInput! = {
5
+ name: "new data"
6
+ }): Data
7
+ }
8
+ ```
@@ -0,0 +1,66 @@
1
+ type Query
2
+ type Mutation
3
+
4
+ extend schema @docs(
5
+ group: ["API & Reference"]
6
+ # above `group` is the root that every node will inherit
7
+ )
8
+
9
+ extend type Query @doc(
10
+ group: ["Users", "Queries"],
11
+ path: "users/queries"
12
+ # `group` and `path` will be inherited by all operations in this type
13
+ ) {
14
+ getUser(id: ID!): User
15
+ @doc(
16
+ path: "get"
17
+ )
18
+ }
19
+
20
+ extend type Query @doc(
21
+ group: ["Todos", "Queries"],
22
+ path: "todos/queries"
23
+ # `group` and `path` will be inherited by all operations in this type
24
+ # NOTE: is a different type from the previous one, so it can have its own `group` and `path`
25
+ ) {
26
+ getTodo(id: ID!): User
27
+ }
28
+
29
+ extend type Mutation @doc(
30
+ group: ["Users", "Mutations"],
31
+ path: "users/mutations"
32
+ ) {
33
+ createUser(input: createUserInput!): User
34
+ # if `path` is not specified, it will be derived from the operation name
35
+ }
36
+
37
+ type User @doc(
38
+ group: ["Users", "Objects"],
39
+ # we can declare `group` for the type itself
40
+ ) {
41
+ id: ID!
42
+ name: String!
43
+ email: String!
44
+ }
45
+
46
+ input createUserInput @doc(
47
+ group: ["Users", "Inputs"],
48
+ # we can declare `group` for the input type itself
49
+ ) {
50
+ name: String!
51
+ email: String!
52
+ }
53
+
54
+ scalar Email @doc(
55
+ group: ["Scalars"]
56
+ # we can declare `group` for the scalar type itself too
57
+ )
58
+
59
+ type Todo @doc(
60
+ group: ["Todos", "Objects"],
61
+ ) {
62
+ id: ID!
63
+ title: String!
64
+ completed: Boolean!
65
+ }
66
+
@@ -0,0 +1,554 @@
1
+ [
2
+ {
3
+ "title": "getUser",
4
+ "description": "",
5
+ "canonical": "users/queries/get",
6
+ "category": "graphql",
7
+ "type": "graphql_query",
8
+ "context": {
9
+ "graphqlTypeShort": "query",
10
+ "graphqlName": "getUser",
11
+ "group": [
12
+ "API & Reference",
13
+ "Users",
14
+ "Queries"
15
+ ],
16
+ "scopes": []
17
+ },
18
+ "examples": {
19
+ "groups": [
20
+ {
21
+ "description": "",
22
+ "examples": [
23
+ {
24
+ "codeblock": {
25
+ "tabs": [
26
+ {
27
+ "title": "",
28
+ "language": "graphql",
29
+ "code": "query getUser($id: ID!) {\n getUser(id: $id) {\n # getUser fields\n }\n}"
30
+ }
31
+ ]
32
+ }
33
+ }
34
+ ]
35
+ }
36
+ ]
37
+ },
38
+ "definitions": [
39
+ {
40
+ "title": "Arguments",
41
+ "properties": [
42
+ {
43
+ "name": "id",
44
+ "type": "ID!",
45
+ "description": "",
46
+ "context": {
47
+ "graphqlName": "id",
48
+ "graphqlTypeFlat": "ID",
49
+ "graphqlBuiltInType": true
50
+ },
51
+ "properties": [],
52
+ "meta": [
53
+ {
54
+ "name": "required",
55
+ "value": "true"
56
+ }
57
+ ],
58
+ "symbolDef": {
59
+ "canonical": ""
60
+ }
61
+ }
62
+ ]
63
+ },
64
+ {
65
+ "title": "Returns",
66
+ "properties": [
67
+ {
68
+ "name": "",
69
+ "type": "User",
70
+ "description": "",
71
+ "context": {
72
+ "graphqlName": "getUser",
73
+ "graphqlTypeFlat": "User",
74
+ "graphqlBuiltInType": false
75
+ },
76
+ "properties": [],
77
+ "meta": [],
78
+ "symbolDef": {
79
+ "canonical": "objects/User"
80
+ }
81
+ }
82
+ ]
83
+ }
84
+ ]
85
+ },
86
+ {
87
+ "title": "getTodo",
88
+ "description": "",
89
+ "canonical": "todos/queries/getTodo",
90
+ "category": "graphql",
91
+ "type": "graphql_query",
92
+ "context": {
93
+ "graphqlTypeShort": "query",
94
+ "graphqlName": "getTodo",
95
+ "group": [
96
+ "API & Reference",
97
+ "Todos",
98
+ "Queries"
99
+ ],
100
+ "scopes": []
101
+ },
102
+ "examples": {
103
+ "groups": [
104
+ {
105
+ "description": "",
106
+ "examples": [
107
+ {
108
+ "codeblock": {
109
+ "tabs": [
110
+ {
111
+ "title": "",
112
+ "language": "graphql",
113
+ "code": "query getTodo($id: ID!) {\n getTodo(id: $id) {\n # getTodo fields\n }\n}"
114
+ }
115
+ ]
116
+ }
117
+ }
118
+ ]
119
+ }
120
+ ]
121
+ },
122
+ "definitions": [
123
+ {
124
+ "title": "Arguments",
125
+ "properties": [
126
+ {
127
+ "name": "id",
128
+ "type": "ID!",
129
+ "description": "",
130
+ "context": {
131
+ "graphqlName": "id",
132
+ "graphqlTypeFlat": "ID",
133
+ "graphqlBuiltInType": true
134
+ },
135
+ "properties": [],
136
+ "meta": [
137
+ {
138
+ "name": "required",
139
+ "value": "true"
140
+ }
141
+ ],
142
+ "symbolDef": {
143
+ "canonical": ""
144
+ }
145
+ }
146
+ ]
147
+ },
148
+ {
149
+ "title": "Returns",
150
+ "properties": [
151
+ {
152
+ "name": "",
153
+ "type": "User",
154
+ "description": "",
155
+ "context": {
156
+ "graphqlName": "getTodo",
157
+ "graphqlTypeFlat": "User",
158
+ "graphqlBuiltInType": false
159
+ },
160
+ "properties": [],
161
+ "meta": [],
162
+ "symbolDef": {
163
+ "canonical": "objects/User"
164
+ }
165
+ }
166
+ ]
167
+ }
168
+ ]
169
+ },
170
+ {
171
+ "title": "createUser",
172
+ "description": "",
173
+ "canonical": "users/mutations/createUser",
174
+ "category": "graphql",
175
+ "type": "graphql_mutation",
176
+ "context": {
177
+ "graphqlTypeShort": "mutation",
178
+ "graphqlName": "createUser",
179
+ "group": [
180
+ "API & Reference",
181
+ "Users",
182
+ "Mutations"
183
+ ],
184
+ "scopes": []
185
+ },
186
+ "examples": {
187
+ "groups": [
188
+ {
189
+ "description": "",
190
+ "examples": [
191
+ {
192
+ "codeblock": {
193
+ "tabs": [
194
+ {
195
+ "title": "",
196
+ "language": "graphql",
197
+ "code": "mutation createUser($input: createUserInput!) {\n createUser(input: $input) {\n # createUser fields\n }\n}"
198
+ }
199
+ ]
200
+ }
201
+ }
202
+ ]
203
+ }
204
+ ]
205
+ },
206
+ "definitions": [
207
+ {
208
+ "title": "Arguments",
209
+ "properties": [
210
+ {
211
+ "name": "input",
212
+ "type": "createUserInput!",
213
+ "description": "",
214
+ "context": {
215
+ "graphqlTypeShort": "input",
216
+ "graphqlName": "createUserInput",
217
+ "group": [
218
+ "API & Reference",
219
+ "Users",
220
+ "Inputs"
221
+ ],
222
+ "scopes": []
223
+ },
224
+ "properties": [],
225
+ "meta": [
226
+ {
227
+ "name": "required",
228
+ "value": "true"
229
+ }
230
+ ],
231
+ "symbolDef": {
232
+ "canonical": "inputs/createUserInput"
233
+ }
234
+ }
235
+ ]
236
+ },
237
+ {
238
+ "title": "Returns",
239
+ "properties": [
240
+ {
241
+ "name": "",
242
+ "type": "User",
243
+ "description": "",
244
+ "context": {
245
+ "graphqlName": "createUser",
246
+ "graphqlTypeFlat": "User",
247
+ "graphqlBuiltInType": false
248
+ },
249
+ "properties": [],
250
+ "meta": [],
251
+ "symbolDef": {
252
+ "canonical": "objects/User"
253
+ }
254
+ }
255
+ ]
256
+ }
257
+ ]
258
+ },
259
+ {
260
+ "title": "User",
261
+ "description": "",
262
+ "canonical": "objects/User",
263
+ "category": "graphql",
264
+ "type": "graphql_object",
265
+ "context": {
266
+ "graphqlTypeShort": "object",
267
+ "graphqlName": "User",
268
+ "group": [
269
+ "API & Reference",
270
+ "Users",
271
+ "Objects"
272
+ ],
273
+ "scopes": []
274
+ },
275
+ "examples": {
276
+ "groups": []
277
+ },
278
+ "definitions": [
279
+ {
280
+ "title": "Arguments",
281
+ "properties": [],
282
+ "variants": [],
283
+ "meta": [
284
+ {
285
+ "name": "type",
286
+ "value": "arguments"
287
+ }
288
+ ]
289
+ },
290
+ {
291
+ "title": "Fields",
292
+ "properties": [
293
+ {
294
+ "name": "id",
295
+ "type": "ID!",
296
+ "description": "",
297
+ "context": {
298
+ "graphqlName": "id",
299
+ "graphqlTypeFlat": "ID",
300
+ "graphqlBuiltInType": true
301
+ },
302
+ "properties": [],
303
+ "meta": [
304
+ {
305
+ "name": "required",
306
+ "value": "true"
307
+ }
308
+ ],
309
+ "symbolDef": {
310
+ "canonical": ""
311
+ }
312
+ },
313
+ {
314
+ "name": "name",
315
+ "type": "String!",
316
+ "description": "",
317
+ "context": {
318
+ "graphqlName": "name",
319
+ "graphqlTypeFlat": "String",
320
+ "graphqlBuiltInType": true
321
+ },
322
+ "properties": [],
323
+ "meta": [
324
+ {
325
+ "name": "required",
326
+ "value": "true"
327
+ }
328
+ ],
329
+ "symbolDef": {
330
+ "canonical": ""
331
+ }
332
+ },
333
+ {
334
+ "name": "email",
335
+ "type": "String!",
336
+ "description": "",
337
+ "context": {
338
+ "graphqlName": "email",
339
+ "graphqlTypeFlat": "String",
340
+ "graphqlBuiltInType": true
341
+ },
342
+ "properties": [],
343
+ "meta": [
344
+ {
345
+ "name": "required",
346
+ "value": "true"
347
+ }
348
+ ],
349
+ "symbolDef": {
350
+ "canonical": ""
351
+ }
352
+ }
353
+ ],
354
+ "meta": [
355
+ {
356
+ "name": "type",
357
+ "value": "fields"
358
+ }
359
+ ]
360
+ }
361
+ ]
362
+ },
363
+ {
364
+ "title": "Todo",
365
+ "description": "",
366
+ "canonical": "objects/Todo",
367
+ "category": "graphql",
368
+ "type": "graphql_object",
369
+ "context": {
370
+ "graphqlTypeShort": "object",
371
+ "graphqlName": "Todo",
372
+ "group": [
373
+ "API & Reference",
374
+ "Todos",
375
+ "Objects"
376
+ ],
377
+ "scopes": []
378
+ },
379
+ "examples": {
380
+ "groups": []
381
+ },
382
+ "definitions": [
383
+ {
384
+ "title": "Arguments",
385
+ "properties": [],
386
+ "variants": [],
387
+ "meta": [
388
+ {
389
+ "name": "type",
390
+ "value": "arguments"
391
+ }
392
+ ]
393
+ },
394
+ {
395
+ "title": "Fields",
396
+ "properties": [
397
+ {
398
+ "name": "id",
399
+ "type": "ID!",
400
+ "description": "",
401
+ "context": {
402
+ "graphqlName": "id",
403
+ "graphqlTypeFlat": "ID",
404
+ "graphqlBuiltInType": true
405
+ },
406
+ "properties": [],
407
+ "meta": [
408
+ {
409
+ "name": "required",
410
+ "value": "true"
411
+ }
412
+ ],
413
+ "symbolDef": {
414
+ "canonical": ""
415
+ }
416
+ },
417
+ {
418
+ "name": "title",
419
+ "type": "String!",
420
+ "description": "",
421
+ "context": {
422
+ "graphqlName": "title",
423
+ "graphqlTypeFlat": "String",
424
+ "graphqlBuiltInType": true
425
+ },
426
+ "properties": [],
427
+ "meta": [
428
+ {
429
+ "name": "required",
430
+ "value": "true"
431
+ }
432
+ ],
433
+ "symbolDef": {
434
+ "canonical": ""
435
+ }
436
+ },
437
+ {
438
+ "name": "completed",
439
+ "type": "Boolean!",
440
+ "description": "",
441
+ "context": {
442
+ "graphqlName": "completed",
443
+ "graphqlTypeFlat": "Boolean",
444
+ "graphqlBuiltInType": true
445
+ },
446
+ "properties": [],
447
+ "meta": [
448
+ {
449
+ "name": "required",
450
+ "value": "true"
451
+ }
452
+ ],
453
+ "symbolDef": {
454
+ "canonical": ""
455
+ }
456
+ }
457
+ ],
458
+ "meta": [
459
+ {
460
+ "name": "type",
461
+ "value": "fields"
462
+ }
463
+ ]
464
+ }
465
+ ]
466
+ },
467
+ {
468
+ "title": "createUserInput",
469
+ "description": "",
470
+ "canonical": "inputs/createUserInput",
471
+ "category": "graphql",
472
+ "type": "graphql_input",
473
+ "context": {
474
+ "graphqlTypeShort": "input",
475
+ "graphqlName": "createUserInput",
476
+ "group": [
477
+ "API & Reference",
478
+ "Users",
479
+ "Inputs"
480
+ ],
481
+ "scopes": []
482
+ },
483
+ "examples": {
484
+ "groups": []
485
+ },
486
+ "definitions": [
487
+ {
488
+ "title": "Fields",
489
+ "properties": [
490
+ {
491
+ "name": "name",
492
+ "type": "String!",
493
+ "description": "",
494
+ "context": {
495
+ "graphqlName": "name",
496
+ "graphqlTypeFlat": "String",
497
+ "graphqlBuiltInType": true
498
+ },
499
+ "properties": [],
500
+ "meta": [
501
+ {
502
+ "name": "required",
503
+ "value": "true"
504
+ }
505
+ ],
506
+ "symbolDef": {
507
+ "canonical": ""
508
+ }
509
+ },
510
+ {
511
+ "name": "email",
512
+ "type": "String!",
513
+ "description": "",
514
+ "context": {
515
+ "graphqlName": "email",
516
+ "graphqlTypeFlat": "String",
517
+ "graphqlBuiltInType": true
518
+ },
519
+ "properties": [],
520
+ "meta": [
521
+ {
522
+ "name": "required",
523
+ "value": "true"
524
+ }
525
+ ],
526
+ "symbolDef": {
527
+ "canonical": ""
528
+ }
529
+ }
530
+ ]
531
+ }
532
+ ]
533
+ },
534
+ {
535
+ "title": "Email",
536
+ "description": "",
537
+ "canonical": "scalars/Email",
538
+ "category": "graphql",
539
+ "type": "graphql_scalar",
540
+ "context": {
541
+ "graphqlTypeShort": "scalar",
542
+ "graphqlName": "Email",
543
+ "group": [
544
+ "API & Reference",
545
+ "Scalars"
546
+ ],
547
+ "scopes": []
548
+ },
549
+ "examples": {
550
+ "groups": []
551
+ },
552
+ "definitions": []
553
+ }
554
+ ]
@@ -0,0 +1,19 @@
1
+ extend schema @docs(
2
+ flattenTypes: true
3
+ )
4
+
5
+ type Author {
6
+ id: ID!
7
+
8
+ name: String!
9
+
10
+ details: AuthorDetails!
11
+ }
12
+
13
+ type AuthorDetails {
14
+ birthDate: String
15
+ }
16
+
17
+ type Query {
18
+ author(id: ID!): Author
19
+ }