@xyd-js/gql 0.1.0-xyd.9 → 0.1.0-xyd.96

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 +810 -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,243 @@
1
+ [
2
+ {
3
+ "title": "author",
4
+ "description": "",
5
+ "canonical": "queries/author",
6
+ "category": "graphql",
7
+ "type": "graphql_query",
8
+ "context": {
9
+ "graphqlTypeShort": "query",
10
+ "graphqlName": "author",
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": "query author($id: ID!) {\n author(id: $id) {\n # author fields\n }\n}"
28
+ }
29
+ ]
30
+ }
31
+ }
32
+ ]
33
+ }
34
+ ]
35
+ },
36
+ "definitions": [
37
+ {
38
+ "title": "Arguments",
39
+ "properties": [
40
+ {
41
+ "name": "id",
42
+ "type": "ID!",
43
+ "description": "",
44
+ "context": {
45
+ "graphqlName": "id",
46
+ "graphqlTypeFlat": "ID",
47
+ "graphqlBuiltInType": true
48
+ },
49
+ "properties": [],
50
+ "meta": [
51
+ {
52
+ "name": "required",
53
+ "value": "true"
54
+ }
55
+ ],
56
+ "symbolDef": {
57
+ "canonical": ""
58
+ }
59
+ }
60
+ ]
61
+ },
62
+ {
63
+ "title": "Returns",
64
+ "properties": [
65
+ {
66
+ "name": "",
67
+ "type": "Author",
68
+ "description": "",
69
+ "context": {
70
+ "graphqlName": "author",
71
+ "graphqlTypeFlat": "Author",
72
+ "graphqlBuiltInType": false
73
+ },
74
+ "properties": [],
75
+ "meta": [],
76
+ "symbolDef": {
77
+ "canonical": "objects/Author"
78
+ }
79
+ }
80
+ ]
81
+ }
82
+ ]
83
+ },
84
+ {
85
+ "title": "Author",
86
+ "description": "",
87
+ "canonical": "objects/Author",
88
+ "category": "graphql",
89
+ "type": "graphql_object",
90
+ "context": {
91
+ "graphqlTypeShort": "object",
92
+ "graphqlName": "Author",
93
+ "group": [
94
+ "Objects"
95
+ ],
96
+ "scopes": []
97
+ },
98
+ "examples": {
99
+ "groups": []
100
+ },
101
+ "definitions": [
102
+ {
103
+ "title": "Arguments",
104
+ "properties": [],
105
+ "variants": [],
106
+ "meta": [
107
+ {
108
+ "name": "type",
109
+ "value": "arguments"
110
+ }
111
+ ]
112
+ },
113
+ {
114
+ "title": "Fields",
115
+ "properties": [
116
+ {
117
+ "name": "id",
118
+ "type": "ID!",
119
+ "description": "",
120
+ "context": {
121
+ "graphqlName": "id",
122
+ "graphqlTypeFlat": "ID",
123
+ "graphqlBuiltInType": true
124
+ },
125
+ "properties": [],
126
+ "meta": [
127
+ {
128
+ "name": "required",
129
+ "value": "true"
130
+ }
131
+ ],
132
+ "symbolDef": {
133
+ "canonical": ""
134
+ }
135
+ },
136
+ {
137
+ "name": "name",
138
+ "type": "String!",
139
+ "description": "",
140
+ "context": {
141
+ "graphqlName": "name",
142
+ "graphqlTypeFlat": "String",
143
+ "graphqlBuiltInType": true
144
+ },
145
+ "properties": [],
146
+ "meta": [
147
+ {
148
+ "name": "required",
149
+ "value": "true"
150
+ }
151
+ ],
152
+ "symbolDef": {
153
+ "canonical": ""
154
+ }
155
+ },
156
+ {
157
+ "name": "details",
158
+ "type": "AuthorDetails!",
159
+ "description": "",
160
+ "context": {
161
+ "graphqlName": "details",
162
+ "graphqlTypeFlat": "AuthorDetails",
163
+ "graphqlBuiltInType": false
164
+ },
165
+ "properties": [],
166
+ "meta": [
167
+ {
168
+ "name": "required",
169
+ "value": "true"
170
+ }
171
+ ],
172
+ "symbolDef": {
173
+ "canonical": "objects/AuthorDetails"
174
+ }
175
+ }
176
+ ],
177
+ "meta": [
178
+ {
179
+ "name": "type",
180
+ "value": "fields"
181
+ }
182
+ ]
183
+ }
184
+ ]
185
+ },
186
+ {
187
+ "title": "AuthorDetails",
188
+ "description": "",
189
+ "canonical": "objects/AuthorDetails",
190
+ "category": "graphql",
191
+ "type": "graphql_object",
192
+ "context": {
193
+ "graphqlTypeShort": "object",
194
+ "graphqlName": "AuthorDetails",
195
+ "group": [
196
+ "Objects"
197
+ ],
198
+ "scopes": []
199
+ },
200
+ "examples": {
201
+ "groups": []
202
+ },
203
+ "definitions": [
204
+ {
205
+ "title": "Arguments",
206
+ "properties": [],
207
+ "variants": [],
208
+ "meta": [
209
+ {
210
+ "name": "type",
211
+ "value": "arguments"
212
+ }
213
+ ]
214
+ },
215
+ {
216
+ "title": "Fields",
217
+ "properties": [
218
+ {
219
+ "name": "birthDate",
220
+ "type": "String",
221
+ "description": "",
222
+ "context": {
223
+ "graphqlName": "birthDate",
224
+ "graphqlTypeFlat": "String",
225
+ "graphqlBuiltInType": true
226
+ },
227
+ "properties": [],
228
+ "meta": [],
229
+ "symbolDef": {
230
+ "canonical": ""
231
+ }
232
+ }
233
+ ],
234
+ "meta": [
235
+ {
236
+ "name": "type",
237
+ "value": "fields"
238
+ }
239
+ ]
240
+ }
241
+ ]
242
+ }
243
+ ]
@@ -0,0 +1,33 @@
1
+ extend enum OpenDocsScope {
2
+ USER_READ @scope(value: "user:read")
3
+
4
+ USER_WRITE @scope(value: "user:write")
5
+ }
6
+
7
+ type User {
8
+ id: ID!
9
+
10
+ name: String!
11
+
12
+ details: UserDetails!
13
+ }
14
+
15
+ type UserDetails {
16
+ birthDate: String
17
+ }
18
+
19
+ input UserWrite {
20
+ name: String!
21
+ }
22
+
23
+ type Query {
24
+ user(id: ID!): User
25
+ @doc(
26
+ scopes: [USER_READ]
27
+ )
28
+
29
+ userAdd(input: UserWrite!): User
30
+ @doc(
31
+ scopes: [USER_READ, "user:write"]
32
+ )
33
+ }
@@ -0,0 +1,378 @@
1
+ [
2
+ {
3
+ "title": "user",
4
+ "description": "",
5
+ "canonical": "queries/user",
6
+ "category": "graphql",
7
+ "type": "graphql_query",
8
+ "context": {
9
+ "graphqlTypeShort": "query",
10
+ "graphqlName": "user",
11
+ "group": [
12
+ "Queries"
13
+ ],
14
+ "scopes": [
15
+ "user:read"
16
+ ]
17
+ },
18
+ "examples": {
19
+ "groups": [
20
+ {
21
+ "description": "",
22
+ "examples": [
23
+ {
24
+ "codeblock": {
25
+ "tabs": [
26
+ {
27
+ "title": "",
28
+ "language": "graphql",
29
+ "code": "query user($id: ID!) {\n user(id: $id) {\n # user 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": "user",
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": "userAdd",
88
+ "description": "",
89
+ "canonical": "queries/userAdd",
90
+ "category": "graphql",
91
+ "type": "graphql_query",
92
+ "context": {
93
+ "graphqlTypeShort": "query",
94
+ "graphqlName": "userAdd",
95
+ "group": [
96
+ "Queries"
97
+ ],
98
+ "scopes": [
99
+ "user:read",
100
+ "user:write"
101
+ ]
102
+ },
103
+ "examples": {
104
+ "groups": [
105
+ {
106
+ "description": "",
107
+ "examples": [
108
+ {
109
+ "codeblock": {
110
+ "tabs": [
111
+ {
112
+ "title": "",
113
+ "language": "graphql",
114
+ "code": "query userAdd($input: UserWrite!) {\n userAdd(input: $input) {\n # userAdd fields\n }\n}"
115
+ }
116
+ ]
117
+ }
118
+ }
119
+ ]
120
+ }
121
+ ]
122
+ },
123
+ "definitions": [
124
+ {
125
+ "title": "Arguments",
126
+ "properties": [
127
+ {
128
+ "name": "input",
129
+ "type": "UserWrite!",
130
+ "description": "",
131
+ "context": {
132
+ "graphqlTypeShort": "input",
133
+ "graphqlName": "UserWrite",
134
+ "group": [
135
+ "Inputs"
136
+ ],
137
+ "scopes": []
138
+ },
139
+ "properties": [],
140
+ "meta": [
141
+ {
142
+ "name": "required",
143
+ "value": "true"
144
+ }
145
+ ],
146
+ "symbolDef": {
147
+ "canonical": "inputs/UserWrite"
148
+ }
149
+ }
150
+ ]
151
+ },
152
+ {
153
+ "title": "Returns",
154
+ "properties": [
155
+ {
156
+ "name": "",
157
+ "type": "User",
158
+ "description": "",
159
+ "context": {
160
+ "graphqlName": "userAdd",
161
+ "graphqlTypeFlat": "User",
162
+ "graphqlBuiltInType": false
163
+ },
164
+ "properties": [],
165
+ "meta": [],
166
+ "symbolDef": {
167
+ "canonical": "objects/User"
168
+ }
169
+ }
170
+ ]
171
+ }
172
+ ]
173
+ },
174
+ {
175
+ "title": "User",
176
+ "description": "",
177
+ "canonical": "objects/User",
178
+ "category": "graphql",
179
+ "type": "graphql_object",
180
+ "context": {
181
+ "graphqlTypeShort": "object",
182
+ "graphqlName": "User",
183
+ "group": [
184
+ "Objects"
185
+ ],
186
+ "scopes": []
187
+ },
188
+ "examples": {
189
+ "groups": []
190
+ },
191
+ "definitions": [
192
+ {
193
+ "title": "Arguments",
194
+ "properties": [],
195
+ "variants": [],
196
+ "meta": [
197
+ {
198
+ "name": "type",
199
+ "value": "arguments"
200
+ }
201
+ ]
202
+ },
203
+ {
204
+ "title": "Fields",
205
+ "properties": [
206
+ {
207
+ "name": "id",
208
+ "type": "ID!",
209
+ "description": "",
210
+ "context": {
211
+ "graphqlName": "id",
212
+ "graphqlTypeFlat": "ID",
213
+ "graphqlBuiltInType": true
214
+ },
215
+ "properties": [],
216
+ "meta": [
217
+ {
218
+ "name": "required",
219
+ "value": "true"
220
+ }
221
+ ],
222
+ "symbolDef": {
223
+ "canonical": ""
224
+ }
225
+ },
226
+ {
227
+ "name": "name",
228
+ "type": "String!",
229
+ "description": "",
230
+ "context": {
231
+ "graphqlName": "name",
232
+ "graphqlTypeFlat": "String",
233
+ "graphqlBuiltInType": true
234
+ },
235
+ "properties": [],
236
+ "meta": [
237
+ {
238
+ "name": "required",
239
+ "value": "true"
240
+ }
241
+ ],
242
+ "symbolDef": {
243
+ "canonical": ""
244
+ }
245
+ },
246
+ {
247
+ "name": "details",
248
+ "type": "UserDetails!",
249
+ "description": "",
250
+ "context": {
251
+ "graphqlName": "details",
252
+ "graphqlTypeFlat": "UserDetails",
253
+ "graphqlBuiltInType": false
254
+ },
255
+ "properties": [],
256
+ "meta": [
257
+ {
258
+ "name": "required",
259
+ "value": "true"
260
+ }
261
+ ],
262
+ "symbolDef": {
263
+ "canonical": "objects/UserDetails"
264
+ }
265
+ }
266
+ ],
267
+ "meta": [
268
+ {
269
+ "name": "type",
270
+ "value": "fields"
271
+ }
272
+ ]
273
+ }
274
+ ]
275
+ },
276
+ {
277
+ "title": "UserDetails",
278
+ "description": "",
279
+ "canonical": "objects/UserDetails",
280
+ "category": "graphql",
281
+ "type": "graphql_object",
282
+ "context": {
283
+ "graphqlTypeShort": "object",
284
+ "graphqlName": "UserDetails",
285
+ "group": [
286
+ "Objects"
287
+ ],
288
+ "scopes": []
289
+ },
290
+ "examples": {
291
+ "groups": []
292
+ },
293
+ "definitions": [
294
+ {
295
+ "title": "Arguments",
296
+ "properties": [],
297
+ "variants": [],
298
+ "meta": [
299
+ {
300
+ "name": "type",
301
+ "value": "arguments"
302
+ }
303
+ ]
304
+ },
305
+ {
306
+ "title": "Fields",
307
+ "properties": [
308
+ {
309
+ "name": "birthDate",
310
+ "type": "String",
311
+ "description": "",
312
+ "context": {
313
+ "graphqlName": "birthDate",
314
+ "graphqlTypeFlat": "String",
315
+ "graphqlBuiltInType": true
316
+ },
317
+ "properties": [],
318
+ "meta": [],
319
+ "symbolDef": {
320
+ "canonical": ""
321
+ }
322
+ }
323
+ ],
324
+ "meta": [
325
+ {
326
+ "name": "type",
327
+ "value": "fields"
328
+ }
329
+ ]
330
+ }
331
+ ]
332
+ },
333
+ {
334
+ "title": "UserWrite",
335
+ "description": "",
336
+ "canonical": "inputs/UserWrite",
337
+ "category": "graphql",
338
+ "type": "graphql_input",
339
+ "context": {
340
+ "graphqlTypeShort": "input",
341
+ "graphqlName": "UserWrite",
342
+ "group": [
343
+ "Inputs"
344
+ ],
345
+ "scopes": []
346
+ },
347
+ "examples": {
348
+ "groups": []
349
+ },
350
+ "definitions": [
351
+ {
352
+ "title": "Fields",
353
+ "properties": [
354
+ {
355
+ "name": "name",
356
+ "type": "String!",
357
+ "description": "",
358
+ "context": {
359
+ "graphqlName": "name",
360
+ "graphqlTypeFlat": "String",
361
+ "graphqlBuiltInType": true
362
+ },
363
+ "properties": [],
364
+ "meta": [
365
+ {
366
+ "name": "required",
367
+ "value": "true"
368
+ }
369
+ ],
370
+ "symbolDef": {
371
+ "canonical": ""
372
+ }
373
+ }
374
+ ]
375
+ }
376
+ ]
377
+ }
378
+ ]
@@ -0,0 +1,44 @@
1
+ extend schema @docs(
2
+ sidebar: [
3
+ {
4
+ group: "API & Reference",
5
+ pages: [
6
+ {
7
+ group: "Users",
8
+ path: "users",
9
+ pages: [
10
+ {
11
+ type: "operation",
12
+ key: "query getUser",
13
+ path: "get",
14
+ },
15
+ {
16
+ type: "operation",
17
+ key: "mutation createUser",
18
+ path: "create"
19
+ }
20
+ ]
21
+ }
22
+ ]
23
+ }
24
+ ]
25
+ )
26
+
27
+ type User {
28
+ id: ID!
29
+ name: String!
30
+ email: String!
31
+ }
32
+
33
+ type Query {
34
+ getUser(id: ID!): User
35
+ }
36
+
37
+ type Mutation{}
38
+
39
+ extend type Mutation @doc(
40
+ group: ["API & Reference", "Users"],
41
+ path: "users"
42
+ ) {
43
+ createUser(name: String!, email: String!): User
44
+ }