@luvio/graphql-parser 0.126.0 → 0.126.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.
Files changed (54) hide show
  1. package/dist/argument-node.d.ts +4 -0
  2. package/dist/ast.d.ts +95 -0
  3. package/dist/constants.d.ts +12 -0
  4. package/dist/directive-node.d.ts +5 -0
  5. package/dist/document.d.ts +3 -0
  6. package/dist/field-node.d.ts +4 -0
  7. package/dist/fragment-spread-node.d.ts +4 -0
  8. package/dist/fragment.d.ts +3 -0
  9. package/dist/gql.d.ts +51 -0
  10. package/dist/inline-fragment-node.d.ts +4 -0
  11. package/dist/luvioGraphqlParser.js +12945 -0
  12. package/dist/luvioGraphqlParser.mjs +12923 -0
  13. package/dist/main.d.ts +18 -0
  14. package/dist/metaschema.d.ts +10 -0
  15. package/dist/operation/index.d.ts +3 -0
  16. package/dist/operation/query/index.d.ts +6 -0
  17. package/dist/type-node.d.ts +3 -0
  18. package/dist/util/language.d.ts +9 -0
  19. package/dist/value-node.d.ts +4 -0
  20. package/dist/variable-definition.d.ts +4 -0
  21. package/dist/visitor.d.ts +4 -0
  22. package/package.json +4 -1
  23. package/babel.config.js +0 -1
  24. package/jest.config.js +0 -8
  25. package/project.json +0 -7
  26. package/rollup.config.js +0 -24
  27. package/scripts/cli.mjs +0 -18
  28. package/src/__tests__/ast.json +0 -403
  29. package/src/__tests__/ast.spec.ts +0 -109
  30. package/src/__tests__/astNoLoc.json +0 -147
  31. package/src/__tests__/gql.spec.ts +0 -665
  32. package/src/__tests__/main.spec.ts +0 -651
  33. package/src/__tests__/metaschema.spec.ts +0 -230
  34. package/src/__tests__/type-node.spec.ts +0 -82
  35. package/src/argument-node.ts +0 -18
  36. package/src/ast.ts +0 -200
  37. package/src/constants.ts +0 -14
  38. package/src/directive-node.ts +0 -36
  39. package/src/document.ts +0 -29
  40. package/src/field-node.ts +0 -72
  41. package/src/fragment-spread-node.ts +0 -28
  42. package/src/fragment.ts +0 -46
  43. package/src/gql.ts +0 -222
  44. package/src/inline-fragment-node.ts +0 -31
  45. package/src/main.ts +0 -134
  46. package/src/metaschema.ts +0 -162
  47. package/src/operation/index.ts +0 -12
  48. package/src/operation/query/index.ts +0 -78
  49. package/src/type-node.ts +0 -40
  50. package/src/util/language.ts +0 -10
  51. package/src/value-node.ts +0 -71
  52. package/src/variable-definition.ts +0 -37
  53. package/src/visitor.ts +0 -63
  54. package/tsconfig.json +0 -9
package/dist/main.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { GraphQLSchema, GraphQLScalarType, execute, buildSchema, getNamedType, isObjectType, validateSchema, NameNode, GraphQLError, ObjectValueNode, defaultFieldResolver, type ASTNode, type DefinitionNode } from 'graphql';
2
+ import { buildASTSchema } from 'graphql/utilities';
3
+ import { LuvioDocumentNode, LuvioArgumentNode, LuvioDefinitionNode, LuvioObjectValueNode, LuvioOperationDefinitionNode, LuvioSelectionCustomFieldNode, LuvioSelectionNode, LuvioSelectionObjectFieldNode, LuvioSelectionScalarFieldNode, LuvioValueNode, LuvioFieldNode, LuvioVariableDefinitionNode, LuvioVariableNode, LuvioNamedTypeNode, LuvioListTypeNode, LuvioListValueNode, LuvioTypeNode } from './ast';
4
+ export type { GraphQLObjectType, GraphQLInterfaceType, GraphQLDirective, GraphQLUnionType, GraphQLNamedType, } from 'graphql/type';
5
+ export type { ListTypeNode, BooleanValueNode, EnumTypeDefinitionNode, FieldDefinitionNode, FloatValueNode, InterfaceTypeDefinitionNode, IntValueNode, NamedTypeNode, ObjectTypeDefinitionNode, StringValueNode, TypeNode, UnionTypeDefinitionNode, DocumentNode, OperationDefinitionNode, FieldNode, ArgumentNode, ValueNode, SelectionNode, SelectionSetNode, FragmentDefinitionNode, DirectiveNode, ObjectFieldNode, ScalarTypeDefinitionNode, InputObjectTypeDefinitionNode, InlineFragmentNode, FragmentSpreadNode, } from 'graphql/language';
6
+ export { ASTVisitor, parse, Kind, print, visit } from 'graphql/language';
7
+ export { isScalarType } from 'graphql/type';
8
+ export { stripIgnoredCharacters } from 'graphql/utilities';
9
+ export { gql, astResolver } from './gql';
10
+ export type { AstResolver } from './gql';
11
+ /**
12
+ * @deprecated - Schema-backed adapters will use standard graphql types re-exported from @luvio/graphql
13
+ */
14
+ export { LuvioDocumentNode, LuvioArgumentNode, LuvioDefinitionNode, LuvioObjectValueNode, LuvioOperationDefinitionNode, LuvioSelectionCustomFieldNode, LuvioSelectionNode, LuvioSelectionObjectFieldNode, LuvioSelectionScalarFieldNode, LuvioValueNode, LuvioFieldNode, LuvioVariableDefinitionNode, LuvioVariableNode, LuvioNamedTypeNode, LuvioListTypeNode, LuvioListValueNode, LuvioTypeNode, GraphQLSchema, GraphQLScalarType, NameNode, GraphQLError, ASTNode, DefinitionNode, ObjectValueNode, buildASTSchema, execute, buildSchema, getNamedType, isObjectType, validateSchema, defaultFieldResolver, };
15
+ /**
16
+ * @deprecated In favor of gql tagged template literal
17
+ */
18
+ export declare function parseAndVisit(source: string): LuvioDocumentNode;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Add metaschema annotations to their corresponding custom notation counterparts
3
+ * @module metaschemaMapper
4
+ */
5
+ import type { DocumentNode } from 'graphql/language';
6
+ /**
7
+ * Accepts a document node and replaces the legacy custom directives with metaschema directives "in-place"
8
+ * @param doc
9
+ */
10
+ export declare function metaschemaMapper(doc: DocumentNode): void;
@@ -0,0 +1,3 @@
1
+ import type { OperationDefinitionNode } from 'graphql/language';
2
+ import type { LuvioOperationDefinitionNode } from '../ast';
3
+ export declare function transform(node: OperationDefinitionNode): LuvioOperationDefinitionNode;
@@ -0,0 +1,6 @@
1
+ import type { OperationDefinitionNode } from 'graphql/language';
2
+ import type { LuvioOperationDefinitionNode } from '../../ast';
3
+ export interface TransformState {
4
+ variablesUsed: Record<string, true>;
5
+ }
6
+ export declare function transform(node: OperationDefinitionNode): LuvioOperationDefinitionNode;
@@ -0,0 +1,3 @@
1
+ import type { TypeNode } from 'graphql/language';
2
+ import type { LuvioTypeNode } from './ast';
3
+ export declare function transform(node: TypeNode): LuvioTypeNode;
@@ -0,0 +1,9 @@
1
+ declare const isArray: (arg: any) => arg is any[];
2
+ declare const create: {
3
+ (o: object | null): any;
4
+ (o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
5
+ }, keys: {
6
+ (o: object): string[];
7
+ (o: {}): string[];
8
+ };
9
+ export { isArray as ArrayIsArray, keys as ObjectKeys, create as ObjectCreate, };
@@ -0,0 +1,4 @@
1
+ import type { ValueNode } from 'graphql/language';
2
+ import type { LuvioValueNode } from './ast';
3
+ import type { TransformState } from './operation/query';
4
+ export declare function transform(node: ValueNode, transformState: TransformState): LuvioValueNode;
@@ -0,0 +1,4 @@
1
+ import type { VariableDefinitionNode } from 'graphql/language';
2
+ import type { LuvioVariableDefinitionNode } from './ast';
3
+ import type { TransformState } from './operation/query';
4
+ export declare function transform(variableDefinitions: VariableDefinitionNode, transformState: TransformState): LuvioVariableDefinitionNode;
@@ -0,0 +1,4 @@
1
+ import type { ASTNode } from 'graphql/language';
2
+ import type { LuvioSelectionNode } from './ast';
3
+ import type { TransformState } from './operation/query';
4
+ export declare function selectionSetVisitor(ast: ASTNode, luvioSelectionPath: LuvioSelectionNode[], transformState: TransformState): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luvio/graphql-parser",
3
- "version": "0.126.0",
3
+ "version": "0.126.1",
4
4
  "description": "GraphQL parser for Luvio GraphQL adapter support",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,6 +15,9 @@
15
15
  "main": "./dist/luvioGraphqlParser.js",
16
16
  "module": "./dist/luvioGraphqlParser.mjs",
17
17
  "types": "dist/main.d.ts",
18
+ "files": [
19
+ "dist/"
20
+ ],
18
21
  "scripts": {
19
22
  "build": "rollup --config rollup.config.js",
20
23
  "clean": "rm -rf dist",
package/babel.config.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('../../../babel.config');
package/jest.config.js DELETED
@@ -1,8 +0,0 @@
1
- const baseConfig = require('../../../scripts/jest/base.config');
2
-
3
- module.exports = {
4
- ...baseConfig,
5
-
6
- displayName: '@luvio/graphql-parser',
7
- roots: ['<rootDir>/src'],
8
- };
package/project.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "root": "packages/@luvio/graphql-parser",
3
- "sourceRoot": "packages/@luvio/graphql-parser/src",
4
- "projectType": "library",
5
- "tags": [],
6
- "implicitDependencies": []
7
- }
package/rollup.config.js DELETED
@@ -1,24 +0,0 @@
1
- import resolve from '@rollup/plugin-node-resolve';
2
- import typescript from 'rollup-plugin-typescript2';
3
-
4
- const luvioGraphqlParserRollupConfig = {
5
- input: './src/main.ts',
6
- output: [
7
- {
8
- file: 'dist/luvioGraphqlParser.js',
9
- format: 'commonjs',
10
- },
11
- {
12
- file: 'dist/luvioGraphqlParser.mjs',
13
- format: 'esm',
14
- },
15
- ],
16
- plugins: [
17
- resolve(),
18
- typescript({
19
- clean: true,
20
- }),
21
- ],
22
- };
23
-
24
- export default luvioGraphqlParserRollupConfig;
package/scripts/cli.mjs DELETED
@@ -1,18 +0,0 @@
1
- import parseAndVisit from '../dist/luvioGraphqlParser.mjs';
2
- import { readFileSync, existsSync } from 'fs';
3
- import { resolve as resolvePath } from 'path';
4
-
5
- const path = process.argv[2];
6
- if (path === undefined) {
7
- throw new Error(`Invalid path "${path}". Usage: "node scripts/cli.mjs PATH/TO/GQL/QUERY.graphql)"`);
8
- }
9
-
10
- if (existsSync(path) === false) {
11
- throw new Error(`Invalid file "${path}", "${path}" does not exist`);
12
- }
13
-
14
- const file = readFileSync(resolvePath(path)).toString();
15
-
16
- const str = parseAndVisit(file);
17
-
18
- console.log(JSON.stringify(str, null, 2));
@@ -1,403 +0,0 @@
1
- {
2
- "kind": "Document",
3
- "definitions": [
4
- {
5
- "kind": "OperationDefinition",
6
- "operation": "query",
7
- "name": {
8
- "kind": "Name",
9
- "value": "GetUser",
10
- "loc": {
11
- "start": 134,
12
- "end": 141
13
- }
14
- },
15
- "variableDefinitions": [
16
- {
17
- "kind": "VariableDefinition",
18
- "variable": {
19
- "kind": "Variable",
20
- "name": {
21
- "kind": "Name",
22
- "value": "userId",
23
- "loc": {
24
- "start": 143,
25
- "end": 149
26
- }
27
- },
28
- "loc": {
29
- "start": 142,
30
- "end": 149
31
- }
32
- },
33
- "type": {
34
- "kind": "NonNullType",
35
- "type": {
36
- "kind": "NamedType",
37
- "name": {
38
- "kind": "Name",
39
- "value": "ID",
40
- "loc": {
41
- "start": 151,
42
- "end": 153
43
- }
44
- },
45
- "loc": {
46
- "start": 151,
47
- "end": 153
48
- }
49
- },
50
- "loc": {
51
- "start": 151,
52
- "end": 154
53
- }
54
- },
55
- "directives": [],
56
- "loc": {
57
- "start": 142,
58
- "end": 154
59
- }
60
- }
61
- ],
62
- "directives": [],
63
- "selectionSet": {
64
- "kind": "SelectionSet",
65
- "selections": [
66
- {
67
- "kind": "Field",
68
- "name": {
69
- "kind": "Name",
70
- "value": "user",
71
- "loc": {
72
- "start": 160,
73
- "end": 164
74
- }
75
- },
76
- "arguments": [
77
- {
78
- "kind": "Argument",
79
- "name": {
80
- "kind": "Name",
81
- "value": "id",
82
- "loc": {
83
- "start": 165,
84
- "end": 167
85
- }
86
- },
87
- "value": {
88
- "kind": "Variable",
89
- "name": {
90
- "kind": "Name",
91
- "value": "userId",
92
- "loc": {
93
- "start": 170,
94
- "end": 176
95
- }
96
- },
97
- "loc": {
98
- "start": 169,
99
- "end": 176
100
- }
101
- },
102
- "loc": {
103
- "start": 165,
104
- "end": 176
105
- }
106
- }
107
- ],
108
- "directives": [],
109
- "selectionSet": {
110
- "kind": "SelectionSet",
111
- "selections": [
112
- {
113
- "kind": "Field",
114
- "name": {
115
- "kind": "Name",
116
- "value": "id",
117
- "loc": {
118
- "start": 184,
119
- "end": 186
120
- }
121
- },
122
- "arguments": [],
123
- "directives": [],
124
- "loc": {
125
- "start": 184,
126
- "end": 186
127
- }
128
- },
129
- {
130
- "kind": "Field",
131
- "name": {
132
- "kind": "Name",
133
- "value": "name",
134
- "loc": {
135
- "start": 192,
136
- "end": 196
137
- }
138
- },
139
- "arguments": [],
140
- "directives": [],
141
- "loc": {
142
- "start": 192,
143
- "end": 196
144
- }
145
- },
146
- {
147
- "kind": "Field",
148
- "name": {
149
- "kind": "Name",
150
- "value": "isViewerFriend",
151
- "loc": {
152
- "start": 202,
153
- "end": 216
154
- }
155
- },
156
- "arguments": [],
157
- "directives": [],
158
- "loc": {
159
- "start": 202,
160
- "end": 216
161
- }
162
- },
163
- {
164
- "kind": "Field",
165
- "name": {
166
- "kind": "Name",
167
- "value": "profilePicture",
168
- "loc": {
169
- "start": 222,
170
- "end": 236
171
- }
172
- },
173
- "arguments": [
174
- {
175
- "kind": "Argument",
176
- "name": {
177
- "kind": "Name",
178
- "value": "size",
179
- "loc": {
180
- "start": 237,
181
- "end": 241
182
- }
183
- },
184
- "value": {
185
- "kind": "IntValue",
186
- "value": "50",
187
- "loc": {
188
- "start": 243,
189
- "end": 245
190
- }
191
- },
192
- "loc": {
193
- "start": 237,
194
- "end": 245
195
- }
196
- }
197
- ],
198
- "directives": [],
199
- "selectionSet": {
200
- "kind": "SelectionSet",
201
- "selections": [
202
- {
203
- "kind": "FragmentSpread",
204
- "name": {
205
- "kind": "Name",
206
- "value": "PictureFragment",
207
- "loc": {
208
- "start": 259,
209
- "end": 274
210
- }
211
- },
212
- "directives": [],
213
- "loc": {
214
- "start": 256,
215
- "end": 274
216
- }
217
- },
218
- {
219
- "kind": "FragmentSpread",
220
- "name": {
221
- "kind": "Name",
222
- "value": "PictureFragmentHeight",
223
- "loc": {
224
- "start": 284,
225
- "end": 305
226
- }
227
- },
228
- "directives": [],
229
- "loc": {
230
- "start": 281,
231
- "end": 305
232
- }
233
- }
234
- ],
235
- "loc": {
236
- "start": 248,
237
- "end": 311
238
- }
239
- },
240
- "loc": {
241
- "start": 222,
242
- "end": 311
243
- }
244
- }
245
- ],
246
- "loc": {
247
- "start": 178,
248
- "end": 315
249
- }
250
- },
251
- "loc": {
252
- "start": 160,
253
- "end": 315
254
- }
255
- }
256
- ],
257
- "loc": {
258
- "start": 156,
259
- "end": 317
260
- }
261
- },
262
- "loc": {
263
- "start": 128,
264
- "end": 317
265
- }
266
- },
267
- {
268
- "kind": "FragmentDefinition",
269
- "name": {
270
- "kind": "Name",
271
- "value": "PictureFragment",
272
- "loc": {
273
- "start": 328,
274
- "end": 343
275
- }
276
- },
277
- "typeCondition": {
278
- "kind": "NamedType",
279
- "name": {
280
- "kind": "Name",
281
- "value": "Picture",
282
- "loc": {
283
- "start": 347,
284
- "end": 354
285
- }
286
- },
287
- "loc": {
288
- "start": 347,
289
- "end": 354
290
- }
291
- },
292
- "directives": [],
293
- "selectionSet": {
294
- "kind": "SelectionSet",
295
- "selections": [
296
- {
297
- "kind": "Field",
298
- "name": {
299
- "kind": "Name",
300
- "value": "uri",
301
- "loc": {
302
- "start": 359,
303
- "end": 362
304
- }
305
- },
306
- "arguments": [],
307
- "directives": [],
308
- "loc": {
309
- "start": 359,
310
- "end": 362
311
- }
312
- },
313
- {
314
- "kind": "Field",
315
- "name": {
316
- "kind": "Name",
317
- "value": "width",
318
- "loc": {
319
- "start": 366,
320
- "end": 371
321
- }
322
- },
323
- "arguments": [],
324
- "directives": [],
325
- "loc": {
326
- "start": 366,
327
- "end": 371
328
- }
329
- }
330
- ],
331
- "loc": {
332
- "start": 355,
333
- "end": 373
334
- }
335
- },
336
- "loc": {
337
- "start": 319,
338
- "end": 373
339
- }
340
- },
341
- {
342
- "kind": "FragmentDefinition",
343
- "name": {
344
- "kind": "Name",
345
- "value": "PictureFragmentHeight",
346
- "loc": {
347
- "start": 384,
348
- "end": 405
349
- }
350
- },
351
- "typeCondition": {
352
- "kind": "NamedType",
353
- "name": {
354
- "kind": "Name",
355
- "value": "Picture",
356
- "loc": {
357
- "start": 409,
358
- "end": 416
359
- }
360
- },
361
- "loc": {
362
- "start": 409,
363
- "end": 416
364
- }
365
- },
366
- "directives": [],
367
- "selectionSet": {
368
- "kind": "SelectionSet",
369
- "selections": [
370
- {
371
- "kind": "Field",
372
- "name": {
373
- "kind": "Name",
374
- "value": "height",
375
- "loc": {
376
- "start": 421,
377
- "end": 427
378
- }
379
- },
380
- "arguments": [],
381
- "directives": [],
382
- "loc": {
383
- "start": 421,
384
- "end": 427
385
- }
386
- }
387
- ],
388
- "loc": {
389
- "start": 417,
390
- "end": 429
391
- }
392
- },
393
- "loc": {
394
- "start": 375,
395
- "end": 429
396
- }
397
- }
398
- ],
399
- "loc": {
400
- "start": 0,
401
- "end": 430
402
- }
403
- }