@graphitation/supermassive 3.0.0-alpha.6 → 3.0.0-alpha.8
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.
- package/.eslintcache +1 -1
- package/CHANGELOG.md +18 -2
- package/README.md +137 -26
- package/lib/__testUtils__/execute.d.ts.map +1 -1
- package/lib/__testUtils__/execute.js +2 -5
- package/lib/__testUtils__/execute.js.map +2 -2
- package/lib/__testUtils__/execute.mjs +2 -5
- package/lib/__testUtils__/execute.mjs.map +2 -2
- package/lib/benchmarks/index.js.map +2 -2
- package/lib/benchmarks/index.mjs.map +2 -2
- package/lib/collectFields.d.ts.map +1 -1
- package/lib/collectFields.js +6 -5
- package/lib/collectFields.js.map +2 -2
- package/lib/collectFields.mjs +6 -5
- package/lib/collectFields.mjs.map +2 -2
- package/lib/executeWithSchema.d.ts +1 -1
- package/lib/executeWithSchema.d.ts.map +1 -1
- package/lib/executeWithSchema.js +9 -23
- package/lib/executeWithSchema.js.map +2 -2
- package/lib/executeWithSchema.mjs +9 -26
- package/lib/executeWithSchema.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +1 -3
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +154 -69
- package/lib/executeWithoutSchema.js.map +2 -2
- package/lib/executeWithoutSchema.mjs +144 -71
- package/lib/executeWithoutSchema.mjs.map +2 -2
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +2 -2
- package/lib/index.mjs +10 -2
- package/lib/index.mjs.map +2 -2
- package/lib/schema/definition.d.ts +43 -33
- package/lib/schema/definition.d.ts.map +1 -1
- package/lib/schema/definition.js +284 -9
- package/lib/schema/definition.js.map +2 -2
- package/lib/schema/definition.mjs +284 -55
- package/lib/schema/definition.mjs.map +3 -3
- package/lib/schema/directives.d.ts.map +1 -1
- package/lib/schema/directives.js +3 -3
- package/lib/schema/directives.js.map +2 -2
- package/lib/schema/directives.mjs +4 -4
- package/lib/schema/directives.mjs.map +2 -2
- package/lib/schema/reference.d.ts +3 -1
- package/lib/schema/reference.d.ts.map +1 -1
- package/lib/schema/reference.js.map +2 -2
- package/lib/schema/reference.mjs.map +2 -2
- package/lib/schema/resolvers.d.ts +10 -4
- package/lib/schema/resolvers.d.ts.map +1 -1
- package/lib/schema/resolvers.js +92 -9
- package/lib/schema/resolvers.js.map +2 -2
- package/lib/schema/resolvers.mjs +99 -9
- package/lib/schema/resolvers.mjs.map +2 -2
- package/lib/subscribeWithSchema.d.ts +1 -1
- package/lib/subscribeWithSchema.d.ts.map +1 -1
- package/lib/subscribeWithSchema.js +9 -23
- package/lib/subscribeWithSchema.js.map +2 -2
- package/lib/subscribeWithSchema.mjs +9 -26
- package/lib/subscribeWithSchema.mjs.map +2 -2
- package/lib/types.d.ts +28 -9
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utilities/coerceInputValue.d.ts +3 -3
- package/lib/utilities/coerceInputValue.d.ts.map +1 -1
- package/lib/utilities/coerceInputValue.js +17 -12
- package/lib/utilities/coerceInputValue.js.map +2 -2
- package/lib/utilities/coerceInputValue.mjs +22 -12
- package/lib/utilities/coerceInputValue.mjs.map +2 -2
- package/lib/utilities/decodeASTSchema.d.ts.map +1 -1
- package/lib/utilities/decodeASTSchema.js +32 -40
- package/lib/utilities/decodeASTSchema.js.map +2 -2
- package/lib/utilities/decodeASTSchema.mjs +51 -49
- package/lib/utilities/decodeASTSchema.mjs.map +2 -2
- package/lib/utilities/encodeASTSchema.d.ts.map +1 -1
- package/lib/utilities/encodeASTSchema.js +16 -20
- package/lib/utilities/encodeASTSchema.js.map +2 -2
- package/lib/utilities/encodeASTSchema.mjs +22 -21
- package/lib/utilities/encodeASTSchema.mjs.map +2 -2
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.d.ts.map +1 -1
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js +20 -22
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js.map +2 -2
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs +35 -29
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs.map +2 -2
- package/lib/utilities/mergeSchemaDefinitions.d.ts.map +1 -1
- package/lib/utilities/mergeSchemaDefinitions.js +18 -28
- package/lib/utilities/mergeSchemaDefinitions.js.map +2 -2
- package/lib/utilities/mergeSchemaDefinitions.mjs +28 -34
- package/lib/utilities/mergeSchemaDefinitions.mjs.map +2 -2
- package/lib/utilities/valueFromAST.d.ts +3 -3
- package/lib/utilities/valueFromAST.d.ts.map +1 -1
- package/lib/utilities/valueFromAST.js +23 -10
- package/lib/utilities/valueFromAST.js.map +2 -2
- package/lib/utilities/valueFromAST.mjs +13 -10
- package/lib/utilities/valueFromAST.mjs.map +2 -2
- package/lib/values.d.ts +2 -2
- package/lib/values.d.ts.map +1 -1
- package/lib/values.js +14 -14
- package/lib/values.js.map +2 -2
- package/lib/values.mjs +21 -14
- package/lib/values.mjs.map +2 -2
- package/package.json +1 -1
- package/lib/schema/fragment.d.ts +0 -63
- package/lib/schema/fragment.d.ts.map +0 -1
- package/lib/schema/fragment.js +0 -295
- package/lib/schema/fragment.js.map +0 -7
- package/lib/schema/fragment.mjs +0 -292
- package/lib/schema/fragment.mjs.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
# Change Log - @graphitation/supermassive
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 14 Sep 2023 19:05:21 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.0.0-alpha.8
|
|
8
|
+
|
|
9
|
+
Thu, 14 Sep 2023 19:05:21 GMT
|
|
10
|
+
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
- change signature of executeWithSchema and subscribeWithSchema functions (vladimir.razuvaev@gmail.com)
|
|
14
|
+
|
|
15
|
+
## 3.0.0-alpha.7
|
|
16
|
+
|
|
17
|
+
Tue, 12 Sep 2023 23:58:31 GMT
|
|
18
|
+
|
|
19
|
+
### Changes
|
|
20
|
+
|
|
21
|
+
- refactor: replace PartialSchema class with ES module functions (vladimir.razuvaev@gmail.com)
|
|
22
|
+
|
|
7
23
|
## 3.0.0-alpha.6
|
|
8
24
|
|
|
9
|
-
Mon, 11 Sep 2023 19:24:
|
|
25
|
+
Mon, 11 Sep 2023 19:24:32 GMT
|
|
10
26
|
|
|
11
27
|
### Changes
|
|
12
28
|
|
package/README.md
CHANGED
|
@@ -27,22 +27,38 @@ Similarly, the GraphQL operations themselves, described using e.g. [GraphQL SDL]
|
|
|
27
27
|
|
|
28
28
|
### Current
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Starting with version 3.0, supermassive expects a compact fragment of the schema alongside documents that are sent to it.
|
|
31
|
+
It doesn't require having a full schema, only a small fragment necessary for a specific operation.
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
Schema fragment format is much more compact than the graphql-js AST. It is optimized for fast merging and serializing,
|
|
34
|
+
so you can incrementally load and merge schema fragments as different operations are requested.
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
Different strategies of "fragmentizing" the schema are possible, it is up to your specific case which strategy to choose.
|
|
37
|
+
Below you can find some strategies that we found useful.
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
need.
|
|
39
|
+
#### 1. Schema fragment by operation
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
We can extract schema fragments by running a pre-processing step on queries, in the same stage where `graphql` tags would normally be extracted and pre-parsed.
|
|
42
|
+
Supermassive package contains several handy utilities for this strategy.
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
#### 2. Schema modules
|
|
45
|
+
|
|
46
|
+
If the schema is big enough, it is a common practice to split it into [multiple modules](https://the-guild.dev/graphql/modules/docs).
|
|
47
|
+
In this case the natural strategy is to generate a single fragment per module. Supermassive supports custom fragment loader,
|
|
48
|
+
so when an operation contains an unknown field or type, supermassive will request a fragment for it.
|
|
49
|
+
This strategy implies "schema map" to properly map operations or individual types to appropriate schema modules
|
|
50
|
+
(schema map generation is out of scope for supermassive itself).
|
|
51
|
+
|
|
52
|
+
#### 3. Variation of the two
|
|
53
|
+
|
|
54
|
+
Other strategies usually represent a variation of those two. E.g. a fragment per specific group of operations, group of modules,
|
|
55
|
+
or mix of modules and operations. Supermassive is agnostic to your "fragmentizing" strategy.
|
|
56
|
+
|
|
57
|
+
### Possible future - pre-normalized executor
|
|
42
58
|
|
|
43
59
|
In a scenario where executor is running close to the client (sometimes even in same process or at least in same browser), it might be worth exploring removing some of the requirements imposed by the usual GraphQL transport - for example serialization. Not only GraphQL executors do the JSON serialization, but also they return the data that is optimized for transport and that matches the query tree. This means clients need to perform often expensive normazilation. As traffic and message size might be less important in same process / same browser scenarios, it might be worthwhile exploring return pre-normalized data from supermassive. This offers massive speedups for some clients like Apollo ([see benchmarks](https://github.com/vladar/graphql-normalized)).
|
|
44
60
|
|
|
45
|
-
### Possible future
|
|
61
|
+
### Possible future - Tree-shaking based on documents
|
|
46
62
|
|
|
47
63
|
Current implementation is more efficient in terms of bundles than one requiring full schema, but resolvers are also not always needed. By going through fields being selected in the documents, resolvers can be split or tree-shook to only load ones that are required for certain frontend bundle.
|
|
48
64
|
|
|
@@ -73,7 +89,7 @@ This would lead to the following [conceptual] tree-shaking after compilation of
|
|
|
73
89
|
};
|
|
74
90
|
```
|
|
75
91
|
|
|
76
|
-
### Possible future
|
|
92
|
+
### Possible future - GraphQL-to-JS
|
|
77
93
|
|
|
78
94
|
We can expand on the previous phase by ahead-of-time compiling the resolution of the operations, their field-resolvers, and invocation thereof into JavaScript code. This essentially does away with any need for AST of the operation during execution. This means execution will be faster as no more generic lookups and checks need to be performed.
|
|
79
95
|
|
|
@@ -142,7 +158,7 @@ function CurrentUserNameQuery(rootSource = {}) {
|
|
|
142
158
|
CurrentUserNameQuery();
|
|
143
159
|
```
|
|
144
160
|
|
|
145
|
-
### Possible future
|
|
161
|
+
### Possible future - persisted queries
|
|
146
162
|
|
|
147
163
|
we can make it possible to replace the operations at runtime using a simple identifier, thus allowing GraphQL clients to execute their operations using these identifiers that they obtain through a concept known as ["persisted queries"](https://relay.dev/docs/guides/persisted-queries/). This means that GraphQL clients that do not require graphql-js AST _themselves_ to operate, such as Relay, will be able to greatly reduce the size of the User-Experience bundles by entirely eliminating the document in favour of a short identifier.
|
|
148
164
|
|
|
@@ -176,15 +192,28 @@ function CurrentUser() {
|
|
|
176
192
|
|
|
177
193
|
## Usage
|
|
178
194
|
|
|
179
|
-
There are 3 main parts of Supermassive
|
|
195
|
+
There are 3 main parts of Supermassive:
|
|
196
|
+
|
|
197
|
+
1. The executor
|
|
198
|
+
2. Minimal viable schema fragment extractor and query annotator (for [schema fragment by operation](#1-schema-fragment-by-operation) strategy)
|
|
199
|
+
3. Schema fragment encoder from/to graphql-js AST (for [schema modules](#2-schema-modules) strategy) + utilities for fragment merging
|
|
200
|
+
|
|
201
|
+
Executor is the part that actually runs the queries. It takes operation document and schema fragment (composed of resolvers and compact type definitions) and optionally, schema fragment loader.
|
|
202
|
+
|
|
203
|
+
Schema fragment extractor process query to extract type definitions necessary to execute this query.
|
|
204
|
+
Query annotator could be used to inline those type definitions into query itself (e.g. as a directive).
|
|
205
|
+
Annotator can be run as part of query extraction stage in Relay Compiler or eg in `@graphitation/graphql-js-tag`.
|
|
206
|
+
|
|
207
|
+
Schema fragment encoder is necessary to produce schema fragments based on [schema modules](#2-schema-modules).
|
|
208
|
+
It takes graphql-js AST of the individual schema module and converts it to the compact schema fragment format.
|
|
180
209
|
|
|
181
210
|
### Executor
|
|
182
211
|
|
|
183
|
-
Two functions are provided - `executeWithSchema` and `executeWithoutSchema`. They attempt to match `graphql-js`'s `execute` function parameters. `executeWithSchema` fully matches it and is meant for development or testing. It does the
|
|
212
|
+
Two functions are provided - `executeWithSchema` and `executeWithoutSchema`. They attempt to match `graphql-js`'s `execute` function parameters. `executeWithSchema` fully matches it and is meant for development or testing. It does the schema fragment extraction for operation in runtime. `executeWithoutSchema` expects schema fragment extracted at build/compile-time, as a required argument.
|
|
184
213
|
|
|
185
|
-
```
|
|
214
|
+
```ts
|
|
186
215
|
interface CommonExecutionArgs {
|
|
187
|
-
|
|
216
|
+
document: DocumentNode;
|
|
188
217
|
rootValue?: unknown;
|
|
189
218
|
contextValue?: unknown;
|
|
190
219
|
variableValues?: Maybe<{ [variable: string]: unknown }>;
|
|
@@ -193,29 +222,111 @@ interface CommonExecutionArgs {
|
|
|
193
222
|
typeResolver?: Maybe<TypeResolver<any, any>>;
|
|
194
223
|
}
|
|
195
224
|
type ExecutionWithoutSchemaArgs = CommonExecutionArgs & {
|
|
196
|
-
|
|
225
|
+
schemaFragment: SchemaFragment;
|
|
226
|
+
schemaFragmentLoader?: SchemaFragmentLoader;
|
|
197
227
|
};
|
|
198
228
|
|
|
199
229
|
type ExecutionWithSchemaArgs = CommonExecutionArgs & {
|
|
200
|
-
|
|
201
|
-
|
|
230
|
+
definitions: DocumentNode;
|
|
231
|
+
resolvers: UserResolvers;
|
|
202
232
|
};
|
|
203
233
|
|
|
204
|
-
function executeWithoutSchema(
|
|
234
|
+
function executeWithoutSchema(
|
|
235
|
+
args: ExecutionWithoutSchemaArgs,
|
|
236
|
+
): PromiseOrValue<ExecutionResult>;
|
|
237
|
+
|
|
238
|
+
function executeWithSchema(
|
|
239
|
+
args: ExecutionWithSchemaArgs,
|
|
240
|
+
): PromiseOrValue<ExecutionResult>;
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Minimal viable schema extractor
|
|
205
244
|
|
|
206
|
-
|
|
245
|
+
Extracts minimal schema fragment necessary for operation execution with supermassive.
|
|
246
|
+
|
|
247
|
+
```ts
|
|
248
|
+
export function extractMinimalViableSchemaForRequestDocument(
|
|
249
|
+
schema: GraphQLSchema,
|
|
250
|
+
requestDocument: DocumentNode,
|
|
251
|
+
): { definitions: SchemaDefinitions; unknownDirectives: DirectiveNode[] };
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Webpack Transform
|
|
255
|
+
|
|
256
|
+
Inlines schema definitions extracted with `extractMinimalViableSchemaForRequestDocument` into the `@schema` directive of each operation / fragment node.
|
|
257
|
+
|
|
258
|
+
With `@graphitation/graphql-js-tag` and `@graphitation/ts-transform-graphql-js-tag` (in webpack config)
|
|
259
|
+
|
|
260
|
+
```js
|
|
261
|
+
import { buildASTSchema } from 'graphql'
|
|
262
|
+
import { getTransformer } from "@graphitation/ts-transform-graphql-js-tag";
|
|
263
|
+
import { annotateDocumentGraphQLTransform } from "@graphitation/supermassive";
|
|
264
|
+
|
|
265
|
+
// ...
|
|
266
|
+
|
|
267
|
+
{
|
|
268
|
+
test: /\.tsx?$/,
|
|
269
|
+
loader: "ts-loader",
|
|
270
|
+
options: {
|
|
271
|
+
getCustomTransformers: () => ({
|
|
272
|
+
before: [
|
|
273
|
+
getTransformer({
|
|
274
|
+
graphqlTagModuleExport: "graphql",
|
|
275
|
+
transformer: annotateDocumentGraphQLTransform(
|
|
276
|
+
buildASTSchema({
|
|
277
|
+
fs.readFileSync(
|
|
278
|
+
"PATH_TO_SCHEMA_TYPEDEFS.graphql",
|
|
279
|
+
{ encoding: "utf-8" }
|
|
280
|
+
),
|
|
281
|
+
)
|
|
282
|
+
),
|
|
283
|
+
}),
|
|
284
|
+
],
|
|
285
|
+
}),
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
}
|
|
207
289
|
```
|
|
208
290
|
|
|
209
|
-
###
|
|
291
|
+
### Schema definitions encoder
|
|
210
292
|
|
|
211
|
-
|
|
293
|
+
Encodes SDL type definitions represented by graphql-js AST to compact format, necessary for execution with supermassive.
|
|
212
294
|
|
|
213
|
-
|
|
295
|
+
```ts
|
|
296
|
+
export function encodeASTSchema(
|
|
297
|
+
schemaFragment: DocumentNode,
|
|
298
|
+
): SchemaDefinitions[];
|
|
299
|
+
export function decodeASTSchema(
|
|
300
|
+
encodedSchemaFragments: SchemaDefinitions[],
|
|
301
|
+
): DocumentNode;
|
|
302
|
+
```
|
|
214
303
|
|
|
215
|
-
|
|
304
|
+
Usage example:
|
|
216
305
|
|
|
217
|
-
```
|
|
218
|
-
|
|
306
|
+
```js
|
|
307
|
+
import { prase } from "graphql";
|
|
308
|
+
import { encodeASTSchema, decodeASTSchema } from "@graphitation/supermassive";
|
|
309
|
+
|
|
310
|
+
const typeDefs = parse(
|
|
311
|
+
fs.readFileSync("PATH_TO_SCHEMA_TYPEDEFS.graphql", { encoding: "utf-8" }),
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
const encodedTypeDefs = encodeASTSchema(typeDefs);
|
|
315
|
+
const decodedTypeDefs = decodeASTSchema(encodedTypeDefs); // decodedTypeDefs are same as typeDefs
|
|
219
316
|
```
|
|
220
317
|
|
|
221
|
-
|
|
318
|
+
### Utilities for definitions and resolvers merging
|
|
319
|
+
|
|
320
|
+
Utilities are useful when it is necessary to produce a single schema fragment from multiple schema fragments.
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
export function mergeSchemaDefinitions(
|
|
324
|
+
accumulator: SchemaDefinitions,
|
|
325
|
+
definitions: SchemaDefinitions[],
|
|
326
|
+
): SchemaDefinitions;
|
|
327
|
+
|
|
328
|
+
export function mergeResolvers(
|
|
329
|
+
accumulator: Resolvers,
|
|
330
|
+
resolvers: (Resolvers | Resolvers[])[],
|
|
331
|
+
): Resolvers;
|
|
332
|
+
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/__testUtils__/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAKb,aAAa,EACb,aAAa,IAAI,oBAAoB,EACrC,eAAe,IAAI,sBAAsB,EAC1C,MAAM,SAAS,CAAC;AAIjB,OAAO,EAAE,eAAe,EAAiB,MAAM,UAAU,CAAC;AAI1D,OAAO,EAAE,cAAc,EAAE,MAAM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AAgB,EAAE,CAChB,IAAI,EAAE,aAAa,KAChB,cAAc,CACjB,cAAc,CAAC,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,eAAe,CAC9D;oEAkCS,aAAa,SACd,MAAM,cACF,OAAO,MAAM,EAAE,OAAO,CAAC;iDAjC1B,aAAa,SACd,MAAM,cACD,OAAO,MAAM,EAAE,OAAO,CAAC;6BAkG3B,eAAe,GAAG,aAAa,KACtC,QAAQ,OAAO,CAAC;sCAhCX,oBAAoB,KACzB,eAAe,aAAa,CAAC;EA8DjC"}
|
|
@@ -84,11 +84,8 @@ function createExecutionUtils(graphqlExecute, graphqlSubscribe) {
|
|
|
84
84
|
const result = yield drainExecution(
|
|
85
85
|
yield (0, import_executeWithSchema.executeWithSchema)({
|
|
86
86
|
document,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
definitions: import_swapi_schema.typeDefs,
|
|
90
|
-
resolvers: import_resolvers.default
|
|
91
|
-
},
|
|
87
|
+
definitions: import_swapi_schema.typeDefs,
|
|
88
|
+
resolvers: import_resolvers.default,
|
|
92
89
|
contextValue: {
|
|
93
90
|
models: import_models.default
|
|
94
91
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/__testUtils__/execute.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n DocumentNode,\n GraphQLSchema,\n Kind,\n OperationDefinitionNode,\n OperationTypeNode,\n parse,\n ExecutionArgs,\n ExecutionArgs as GraphQLExecutionArgs,\n ExecutionResult as GraphQLExecutionResult,\n} from \"graphql\";\nimport { executeWithSchema } from \"../executeWithSchema\";\nimport { typeDefs } from \"../benchmarks/swapi-schema\";\nimport resolvers from \"../benchmarks/swapi-schema/resolvers\";\nimport { ExecutionResult, UserResolvers } from \"../types\";\nimport models from \"../benchmarks/swapi-schema/models\";\nimport { executeWithoutSchema } from \"../executeWithoutSchema\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/extractMinimalViableSchemaForRequestDocument\";\nimport { PromiseOrValue } from \"graphql/jsutils/PromiseOrValue\";\nimport { ObjMap } from \"../jsutils/ObjMap\";\nimport { forAwaitEach, isAsyncIterable } from \"iterall\";\n\ntype GraphQLResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> =\n | GraphQLExecutionResult<TData, TExtensions>\n | AsyncGenerator<GraphQLExecutionResult<TData, TExtensions>, void, void>;\n\nexport function createExecutionUtils(\n graphqlExecute: (args: ExecutionArgs) => PromiseOrValue<ExecutionResult>,\n graphqlSubscribe: (\n args: ExecutionArgs,\n ) => PromiseOrValue<\n AsyncGenerator<ExecutionResult, void, void> | ExecutionResult\n >,\n) {\n async function compareResultsForExecuteWithSchema(\n schema: GraphQLSchema,\n query: string,\n variables?: Record<string, unknown>,\n ) {\n expect.assertions(1);\n const document = parse(query);\n const result = await drainExecution(\n await executeWithSchema({\n document,\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAUO;AACP,+BAAkC;AAClC,0BAAyB;AACzB,uBAAsB;AAEtB,oBAAmB;AACnB,kCAAqC;AACrC,0DAA6D;AAG7D,qBAA8C;AAMvC,SAAS,qBACd,gBACA,kBAKA;AACA,WAAe,mCACb,QACA,OACA,WACA;AAAA;AACA,aAAO,WAAW,CAAC;AACnB,YAAM,eAAW,sBAAM,KAAK;AAC5B,YAAM,SAAS,MAAM;AAAA,QACnB,UAAM,4CAAkB;AAAA,UACtB;AAAA,UACA,
|
|
4
|
+
"sourcesContent": ["import {\n DocumentNode,\n GraphQLSchema,\n Kind,\n OperationDefinitionNode,\n OperationTypeNode,\n parse,\n ExecutionArgs,\n ExecutionArgs as GraphQLExecutionArgs,\n ExecutionResult as GraphQLExecutionResult,\n} from \"graphql\";\nimport { executeWithSchema } from \"../executeWithSchema\";\nimport { typeDefs } from \"../benchmarks/swapi-schema\";\nimport resolvers from \"../benchmarks/swapi-schema/resolvers\";\nimport { ExecutionResult, UserResolvers } from \"../types\";\nimport models from \"../benchmarks/swapi-schema/models\";\nimport { executeWithoutSchema } from \"../executeWithoutSchema\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/extractMinimalViableSchemaForRequestDocument\";\nimport { PromiseOrValue } from \"graphql/jsutils/PromiseOrValue\";\nimport { ObjMap } from \"../jsutils/ObjMap\";\nimport { forAwaitEach, isAsyncIterable } from \"iterall\";\n\ntype GraphQLResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> =\n | GraphQLExecutionResult<TData, TExtensions>\n | AsyncGenerator<GraphQLExecutionResult<TData, TExtensions>, void, void>;\n\nexport function createExecutionUtils(\n graphqlExecute: (args: ExecutionArgs) => PromiseOrValue<ExecutionResult>,\n graphqlSubscribe: (\n args: ExecutionArgs,\n ) => PromiseOrValue<\n AsyncGenerator<ExecutionResult, void, void> | ExecutionResult\n >,\n) {\n async function compareResultsForExecuteWithSchema(\n schema: GraphQLSchema,\n query: string,\n variables?: Record<string, unknown>,\n ) {\n expect.assertions(1);\n const document = parse(query);\n const result = await drainExecution(\n await executeWithSchema({\n document,\n definitions: typeDefs,\n resolvers: resolvers as UserResolvers<unknown, unknown>,\n contextValue: {\n models,\n },\n variableValues: variables,\n }),\n );\n const validResult = await drainExecution(\n await graphqlExecuteOrSubscribe({\n document,\n contextValue: {\n models,\n },\n schema,\n variableValues: variables,\n }),\n );\n expect(result).toEqual(validResult);\n }\n\n async function compareResultForExecuteWithoutSchemaWithMVSAnnotation(\n schema: GraphQLSchema,\n query: string,\n variables: Record<string, unknown> = {},\n ) {\n expect.assertions(1);\n const document = parse(query);\n const { definitions } = extractMinimalViableSchemaForRequestDocument(\n schema,\n document,\n );\n const result = await drainExecution(\n await executeWithoutSchema({\n document,\n contextValue: {\n models,\n },\n schemaFragment: {\n schemaId: \"test\",\n definitions,\n resolvers: resolvers as UserResolvers,\n },\n variableValues: variables,\n }),\n );\n const validResult = await drainExecution(\n await graphqlExecuteOrSubscribe({\n document,\n contextValue: {\n models,\n },\n schema,\n variableValues: variables,\n }),\n );\n expect(result).toEqual(validResult);\n }\n\n function graphqlExecuteOrSubscribe(\n args: GraphQLExecutionArgs,\n ): PromiseOrValue<GraphQLResult> {\n const operationName = args.operationName;\n let operation: OperationDefinitionNode | undefined;\n for (const definition of (args.document as unknown as DocumentNode)\n .definitions) {\n switch (definition.kind) {\n case Kind.OPERATION_DEFINITION:\n if (operationName == null) {\n if (operation !== undefined) {\n throw new Error(\"Bad operation in test\");\n }\n operation = definition;\n } else if (definition.name?.value === operationName) {\n operation = definition;\n }\n break;\n }\n }\n if (!operation) {\n throw new Error(\"Bad operation in test\");\n }\n\n if (operation.operation === OperationTypeNode.SUBSCRIPTION) {\n return graphqlSubscribe(args) as GraphQLResult;\n } else {\n return graphqlExecute(args) as GraphQLResult;\n }\n }\n\n async function drainExecution(\n result: ExecutionResult | GraphQLResult,\n ): Promise<unknown> {\n let processedResult;\n if (isAsyncIterable(result)) {\n processedResult = await drainAsyncGeneratorToArray(result);\n } else if (\"subsequentResults\" in result) {\n processedResult = {\n ...result,\n subsequentResults: await drainAsyncGeneratorToArray(\n result.subsequentResults,\n ),\n };\n } else {\n processedResult = result;\n }\n return processedResult;\n }\n\n async function drainAsyncGeneratorToArray<T>(\n collection: AsyncGenerator<T, void, void>,\n ): Promise<T[]> {\n const result: T[] = [];\n await forAwaitEach(collection, (item) => result.push(item));\n return result;\n }\n\n return {\n compareResultForExecuteWithoutSchemaWithMVSAnnotation,\n compareResultsForExecuteWithSchema,\n drainExecution,\n graphqlExecuteOrSubscribe,\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAUO;AACP,+BAAkC;AAClC,0BAAyB;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, graphqlSubscribe) {
|
|
|
59
59
|
const result = yield drainExecution(
|
|
60
60
|
yield executeWithSchema({
|
|
61
61
|
document,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
definitions: typeDefs,
|
|
65
|
-
resolvers
|
|
66
|
-
},
|
|
62
|
+
definitions: typeDefs,
|
|
63
|
+
resolvers,
|
|
67
64
|
contextValue: {
|
|
68
65
|
models
|
|
69
66
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/__testUtils__/execute.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n DocumentNode,\n GraphQLSchema,\n Kind,\n OperationDefinitionNode,\n OperationTypeNode,\n parse,\n ExecutionArgs,\n ExecutionArgs as GraphQLExecutionArgs,\n ExecutionResult as GraphQLExecutionResult,\n} from \"graphql\";\nimport { executeWithSchema } from \"../executeWithSchema\";\nimport { typeDefs } from \"../benchmarks/swapi-schema\";\nimport resolvers from \"../benchmarks/swapi-schema/resolvers\";\nimport { ExecutionResult, UserResolvers } from \"../types\";\nimport models from \"../benchmarks/swapi-schema/models\";\nimport { executeWithoutSchema } from \"../executeWithoutSchema\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/extractMinimalViableSchemaForRequestDocument\";\nimport { PromiseOrValue } from \"graphql/jsutils/PromiseOrValue\";\nimport { ObjMap } from \"../jsutils/ObjMap\";\nimport { forAwaitEach, isAsyncIterable } from \"iterall\";\n\ntype GraphQLResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> =\n | GraphQLExecutionResult<TData, TExtensions>\n | AsyncGenerator<GraphQLExecutionResult<TData, TExtensions>, void, void>;\n\nexport function createExecutionUtils(\n graphqlExecute: (args: ExecutionArgs) => PromiseOrValue<ExecutionResult>,\n graphqlSubscribe: (\n args: ExecutionArgs,\n ) => PromiseOrValue<\n AsyncGenerator<ExecutionResult, void, void> | ExecutionResult\n >,\n) {\n async function compareResultsForExecuteWithSchema(\n schema: GraphQLSchema,\n query: string,\n variables?: Record<string, unknown>,\n ) {\n expect.assertions(1);\n const document = parse(query);\n const result = await drainExecution(\n await executeWithSchema({\n document,\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EAGE;AAAA,EAEA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AACzB,OAAO,eAAe;AAEtB,OAAO,YAAY;AACnB,SAAS,4BAA4B;AACrC,SAAS,oDAAoD;AAG7D,SAAS,cAAc,uBAAuB;AAMvC,SAAS,qBACd,gBACA,kBAKA;AACA,WAAe,mCACb,QACA,OACA,WACA;AAAA;AACA,aAAO,WAAW,CAAC;AACnB,YAAM,WAAW,MAAM,KAAK;AAC5B,YAAM,SAAS,MAAM;AAAA,QACnB,MAAM,kBAAkB;AAAA,UACtB;AAAA,UACA,
|
|
4
|
+
"sourcesContent": ["import {\n DocumentNode,\n GraphQLSchema,\n Kind,\n OperationDefinitionNode,\n OperationTypeNode,\n parse,\n ExecutionArgs,\n ExecutionArgs as GraphQLExecutionArgs,\n ExecutionResult as GraphQLExecutionResult,\n} from \"graphql\";\nimport { executeWithSchema } from \"../executeWithSchema\";\nimport { typeDefs } from \"../benchmarks/swapi-schema\";\nimport resolvers from \"../benchmarks/swapi-schema/resolvers\";\nimport { ExecutionResult, UserResolvers } from \"../types\";\nimport models from \"../benchmarks/swapi-schema/models\";\nimport { executeWithoutSchema } from \"../executeWithoutSchema\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/extractMinimalViableSchemaForRequestDocument\";\nimport { PromiseOrValue } from \"graphql/jsutils/PromiseOrValue\";\nimport { ObjMap } from \"../jsutils/ObjMap\";\nimport { forAwaitEach, isAsyncIterable } from \"iterall\";\n\ntype GraphQLResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> =\n | GraphQLExecutionResult<TData, TExtensions>\n | AsyncGenerator<GraphQLExecutionResult<TData, TExtensions>, void, void>;\n\nexport function createExecutionUtils(\n graphqlExecute: (args: ExecutionArgs) => PromiseOrValue<ExecutionResult>,\n graphqlSubscribe: (\n args: ExecutionArgs,\n ) => PromiseOrValue<\n AsyncGenerator<ExecutionResult, void, void> | ExecutionResult\n >,\n) {\n async function compareResultsForExecuteWithSchema(\n schema: GraphQLSchema,\n query: string,\n variables?: Record<string, unknown>,\n ) {\n expect.assertions(1);\n const document = parse(query);\n const result = await drainExecution(\n await executeWithSchema({\n document,\n definitions: typeDefs,\n resolvers: resolvers as UserResolvers<unknown, unknown>,\n contextValue: {\n models,\n },\n variableValues: variables,\n }),\n );\n const validResult = await drainExecution(\n await graphqlExecuteOrSubscribe({\n document,\n contextValue: {\n models,\n },\n schema,\n variableValues: variables,\n }),\n );\n expect(result).toEqual(validResult);\n }\n\n async function compareResultForExecuteWithoutSchemaWithMVSAnnotation(\n schema: GraphQLSchema,\n query: string,\n variables: Record<string, unknown> = {},\n ) {\n expect.assertions(1);\n const document = parse(query);\n const { definitions } = extractMinimalViableSchemaForRequestDocument(\n schema,\n document,\n );\n const result = await drainExecution(\n await executeWithoutSchema({\n document,\n contextValue: {\n models,\n },\n schemaFragment: {\n schemaId: \"test\",\n definitions,\n resolvers: resolvers as UserResolvers,\n },\n variableValues: variables,\n }),\n );\n const validResult = await drainExecution(\n await graphqlExecuteOrSubscribe({\n document,\n contextValue: {\n models,\n },\n schema,\n variableValues: variables,\n }),\n );\n expect(result).toEqual(validResult);\n }\n\n function graphqlExecuteOrSubscribe(\n args: GraphQLExecutionArgs,\n ): PromiseOrValue<GraphQLResult> {\n const operationName = args.operationName;\n let operation: OperationDefinitionNode | undefined;\n for (const definition of (args.document as unknown as DocumentNode)\n .definitions) {\n switch (definition.kind) {\n case Kind.OPERATION_DEFINITION:\n if (operationName == null) {\n if (operation !== undefined) {\n throw new Error(\"Bad operation in test\");\n }\n operation = definition;\n } else if (definition.name?.value === operationName) {\n operation = definition;\n }\n break;\n }\n }\n if (!operation) {\n throw new Error(\"Bad operation in test\");\n }\n\n if (operation.operation === OperationTypeNode.SUBSCRIPTION) {\n return graphqlSubscribe(args) as GraphQLResult;\n } else {\n return graphqlExecute(args) as GraphQLResult;\n }\n }\n\n async function drainExecution(\n result: ExecutionResult | GraphQLResult,\n ): Promise<unknown> {\n let processedResult;\n if (isAsyncIterable(result)) {\n processedResult = await drainAsyncGeneratorToArray(result);\n } else if (\"subsequentResults\" in result) {\n processedResult = {\n ...result,\n subsequentResults: await drainAsyncGeneratorToArray(\n result.subsequentResults,\n ),\n };\n } else {\n processedResult = result;\n }\n return processedResult;\n }\n\n async function drainAsyncGeneratorToArray<T>(\n collection: AsyncGenerator<T, void, void>,\n ): Promise<T[]> {\n const result: T[] = [];\n await forAwaitEach(collection, (item) => result.push(item));\n return result;\n }\n\n return {\n compareResultForExecuteWithoutSchemaWithMVSAnnotation,\n compareResultsForExecuteWithSchema,\n drainExecution,\n graphqlExecuteOrSubscribe,\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EAGE;AAAA,EAEA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AACzB,OAAO,eAAe;AAEtB,OAAO,YAAY;AACnB,SAAS,4BAA4B;AACrC,SAAS,oDAAoD;AAG7D,SAAS,cAAc,uBAAuB;AAMvC,SAAS,qBACd,gBACA,kBAKA;AACA,WAAe,mCACb,QACA,OACA,WACA;AAAA;AACA,aAAO,WAAW,CAAC;AACnB,YAAM,WAAW,MAAM,KAAK;AAC5B,YAAM,SAAS,MAAM;AAAA,QACnB,MAAM,kBAAkB;AAAA,UACtB;AAAA,UACA,aAAa;AAAA,UACb;AAAA,UACA,cAAc;AAAA,YACZ;AAAA,UACF;AAAA,UACA,gBAAgB;AAAA,QAClB,CAAC;AAAA,MACH;AACA,YAAM,cAAc,MAAM;AAAA,QACxB,M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,IACzC;AAEA,QAAI,UAAU,cAAc,kBAAkB,cAAc;AAC1D,aAAO,iBAAiB,IAAI;AAAA,IAC9B,OAAO;AACL,aAAO,eAAe,IAAI;AAAA,IAC5B;AAAA,EACF;AAEA,WAAe,eACb,QACkB;AAAA;AAClB,UAAI;AACJ,UAAI,gBAAgB,MAAM,GAAG;AAC3B,0BAAkB,MAAM,2BAA2B,MAAM;AAAA,MAC3D,WAAW,uBAAuB,QAAQ;AACxC,0BAAkB,iCACb,SADa;AAAA,UAEhB,mBAAmB,MAAM;AAAA,YACvB,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF,OAAO;AACL,0BAAkB;AAAA,MACpB;AACA,aAAO;AAAA,IACT;AAAA;AAEA,WAAe,2BACb,YACc;AAAA;AACd,YAAM,SAAc,CAAC;AACrB,YAAM,aAAa,YAAY,CAAC,SAAS,OAAO,KAAK,IAAI,CAAC;AAC1D,aAAO;AAAA,IACT;AAAA;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/benchmarks/index.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from \"fs\";\nimport path from \"path\";\nimport NiceBenchmark from \"./nice-benchmark\";\nimport schema from \"./swapi-schema\";\nimport resolvers from \"./swapi-schema/resolvers\";\nimport models from \"./swapi-schema/models\";\nimport {\n execute as graphqlExecute,\n parse,\n // experimentalExecuteIncrementally as graphqlExecute,\n} from \"graphql\";\nimport { compileQuery, isCompiledQuery } from \"graphql-jit\";\nimport { executeWithoutSchema as supermassiveExecute } from \"../executeWithoutSchema\";\nimport { UserResolvers } from \"../types\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/extractMinimalViableSchemaForRequestDocument\";\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gBAAe;AACf,kBAAiB;AACjB,4BAA0B;AAC1B,0BAAmB;AACnB,uBAAsB;AACtB,oBAAmB;AACnB,qBAIO;AACP,yBAA8C;AAC9C,kCAA4D;AAE5D,0DAA6D;
|
|
4
|
+
"sourcesContent": ["import fs from \"fs\";\nimport path from \"path\";\nimport NiceBenchmark from \"./nice-benchmark\";\nimport schema from \"./swapi-schema\";\nimport resolvers from \"./swapi-schema/resolvers\";\nimport models from \"./swapi-schema/models\";\nimport {\n execute as graphqlExecute,\n parse,\n // experimentalExecuteIncrementally as graphqlExecute,\n} from \"graphql\";\nimport { compileQuery, isCompiledQuery } from \"graphql-jit\";\nimport { executeWithoutSchema as supermassiveExecute } from \"../executeWithoutSchema\";\nimport { UserResolvers, SchemaFragment } from \"../types\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/extractMinimalViableSchemaForRequestDocument\";\n\nconst query = fs.readFileSync(\n path.join(__dirname, \"./fixtures/query1.graphql\"),\n {\n encoding: \"utf-8\",\n },\n);\n\nconst parsedQuery = parse(query);\nconst compiledQuery = compileQuery(schema, parsedQuery);\n\nconst { definitions } = extractMinimalViableSchemaForRequestDocument(\n schema,\n parsedQuery,\n);\n\nconst schemaFragment: SchemaFragment = {\n schemaId: \"benchmark\",\n definitions,\n resolvers: resolvers as UserResolvers,\n};\n\nconst queryRunningSuite = new NiceBenchmark(\"Query Running\");\nqueryRunningSuite.add(\"graphql-js - string queries\", async () => {\n const result = await graphqlExecute({\n schema,\n document: parse(query),\n contextValue: { models },\n });\n if (result.errors || !result.data) {\n throw new Error(\"Stuff ain't executing\");\n }\n});\nqueryRunningSuite.add(\"graphql-js - parsed queries\", async () => {\n const result = await graphqlExecute({\n schema,\n document: parsedQuery,\n contextValue: { models },\n });\n if (result.errors || !result.data) {\n throw new Error(\"Stuff ain't executing\");\n }\n});\nqueryRunningSuite.add(\"graphql-jit - uncompiled\", async () => {\n const freshCompiledQuery = compileQuery(schema, parsedQuery);\n if (isCompiledQuery(freshCompiledQuery)) {\n const result = await freshCompiledQuery.query({}, { models }, {});\n if (result.errors || !result.data) {\n throw new Error(\"Stuff ain't executing\");\n }\n } else {\n throw new Error(\"Wrong query\");\n }\n});\nqueryRunningSuite.add(\"graphql-jit - precompiled\", async () => {\n if (isCompiledQuery(compiledQuery)) {\n const result = await compiledQuery.query({}, { models }, {});\n if (result.errors || !result.data) {\n throw new Error(\"Stuff ain't executing\");\n }\n } else {\n throw new Error(\"Wrong query\");\n }\n});\nqueryRunningSuite.add(\"supermassive - runtime schemaless\", async () => {\n const result = await supermassiveExecute({\n schemaFragment,\n document: parsedQuery,\n contextValue: { models },\n });\n if (\"data\" in result && (result.errors || !result.data)) {\n throw new Error(\"Stuff ain't executing\");\n }\n});\n\nconst queryParsingSuite = new NiceBenchmark(\"Query parsing\");\nqueryParsingSuite.add(\"graphql-js\", async () => {\n parse(query);\n});\n\nconst queryCompilingSuite = new NiceBenchmark(\"Query compiling\");\nqueryCompilingSuite.add(\"graphql-jit\", async () => {\n await compileQuery(schema, parsedQuery);\n});\n\nconst queryAnnotationSuite = new NiceBenchmark(\"Query annotation\");\nqueryAnnotationSuite.add(\"supermassive\", () => {\n extractMinimalViableSchemaForRequestDocument(schema, parsedQuery);\n});\n\nasync function main() {\n await queryCompilingSuite.run();\n await queryParsingSuite.run();\n await queryAnnotationSuite.run();\n await queryRunningSuite.run();\n}\n\nmain();\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gBAAe;AACf,kBAAiB;AACjB,4BAA0B;AAC1B,0BAAmB;AACnB,uBAAsB;AACtB,oBAAmB;AACnB,qBAIO;AACP,yBAA8C;AAC9C,kCAA4D;AAE5D,0DAA6D;AAE7D,MAAM,QAAQ,UAAAA,QAAG;AAAA,EACf,YAAAC,QAAK,KAAK,WAAW,2BAA2B;AAAA,EAChD;AAAA,IACE,UAAU;AAAA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version": 3,
|
|
3
3
|
"sources": ["../../src/benchmarks/index.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from \"fs\";\nimport path from \"path\";\nimport NiceBenchmark from \"./nice-benchmark\";\nimport schema from \"./swapi-schema\";\nimport resolvers from \"./swapi-schema/resolvers\";\nimport models from \"./swapi-schema/models\";\nimport {\n execute as graphqlExecute,\n parse,\n // experimentalExecuteIncrementally as graphqlExecute,\n} from \"graphql\";\nimport { compileQuery, isCompiledQuery } from \"graphql-jit\";\nimport { executeWithoutSchema as supermassiveExecute } from \"../executeWithoutSchema\";\nimport { UserResolvers } from \"../types\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/extractMinimalViableSchemaForRequestDocument\";\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,mBAAmB;AAC1B,OAAO,YAAY;AACnB,OAAO,eAAe;AACtB,OAAO,YAAY;AACnB;AAAA,EACE,WAAW;AAAA,EACX;AAAA,OAEK;AACP,SAAS,cAAc,uBAAuB;AAC9C,SAAS,wBAAwB,2BAA2B;AAE5D,SAAS,oDAAoD;AAd7D;AAAA;
|
|
4
|
+
"sourcesContent": ["import fs from \"fs\";\nimport path from \"path\";\nimport NiceBenchmark from \"./nice-benchmark\";\nimport schema from \"./swapi-schema\";\nimport resolvers from \"./swapi-schema/resolvers\";\nimport models from \"./swapi-schema/models\";\nimport {\n execute as graphqlExecute,\n parse,\n // experimentalExecuteIncrementally as graphqlExecute,\n} from \"graphql\";\nimport { compileQuery, isCompiledQuery } from \"graphql-jit\";\nimport { executeWithoutSchema as supermassiveExecute } from \"../executeWithoutSchema\";\nimport { UserResolvers, SchemaFragment } from \"../types\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/extractMinimalViableSchemaForRequestDocument\";\n\nconst query = fs.readFileSync(\n path.join(__dirname, \"./fixtures/query1.graphql\"),\n {\n encoding: \"utf-8\",\n },\n);\n\nconst parsedQuery = parse(query);\nconst compiledQuery = compileQuery(schema, parsedQuery);\n\nconst { definitions } = extractMinimalViableSchemaForRequestDocument(\n schema,\n parsedQuery,\n);\n\nconst schemaFragment: SchemaFragment = {\n schemaId: \"benchmark\",\n definitions,\n resolvers: resolvers as UserResolvers,\n};\n\nconst queryRunningSuite = new NiceBenchmark(\"Query Running\");\nqueryRunningSuite.add(\"graphql-js - string queries\", async () => {\n const result = await graphqlExecute({\n schema,\n document: parse(query),\n contextValue: { models },\n });\n if (result.errors || !result.data) {\n throw new Error(\"Stuff ain't executing\");\n }\n});\nqueryRunningSuite.add(\"graphql-js - parsed queries\", async () => {\n const result = await graphqlExecute({\n schema,\n document: parsedQuery,\n contextValue: { models },\n });\n if (result.errors || !result.data) {\n throw new Error(\"Stuff ain't executing\");\n }\n});\nqueryRunningSuite.add(\"graphql-jit - uncompiled\", async () => {\n const freshCompiledQuery = compileQuery(schema, parsedQuery);\n if (isCompiledQuery(freshCompiledQuery)) {\n const result = await freshCompiledQuery.query({}, { models }, {});\n if (result.errors || !result.data) {\n throw new Error(\"Stuff ain't executing\");\n }\n } else {\n throw new Error(\"Wrong query\");\n }\n});\nqueryRunningSuite.add(\"graphql-jit - precompiled\", async () => {\n if (isCompiledQuery(compiledQuery)) {\n const result = await compiledQuery.query({}, { models }, {});\n if (result.errors || !result.data) {\n throw new Error(\"Stuff ain't executing\");\n }\n } else {\n throw new Error(\"Wrong query\");\n }\n});\nqueryRunningSuite.add(\"supermassive - runtime schemaless\", async () => {\n const result = await supermassiveExecute({\n schemaFragment,\n document: parsedQuery,\n contextValue: { models },\n });\n if (\"data\" in result && (result.errors || !result.data)) {\n throw new Error(\"Stuff ain't executing\");\n }\n});\n\nconst queryParsingSuite = new NiceBenchmark(\"Query parsing\");\nqueryParsingSuite.add(\"graphql-js\", async () => {\n parse(query);\n});\n\nconst queryCompilingSuite = new NiceBenchmark(\"Query compiling\");\nqueryCompilingSuite.add(\"graphql-jit\", async () => {\n await compileQuery(schema, parsedQuery);\n});\n\nconst queryAnnotationSuite = new NiceBenchmark(\"Query annotation\");\nqueryAnnotationSuite.add(\"supermassive\", () => {\n extractMinimalViableSchemaForRequestDocument(schema, parsedQuery);\n});\n\nasync function main() {\n await queryCompilingSuite.run();\n await queryParsingSuite.run();\n await queryAnnotationSuite.run();\n await queryRunningSuite.run();\n}\n\nmain();\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,mBAAmB;AAC1B,OAAO,YAAY;AACnB,OAAO,eAAe;AACtB,OAAO,YAAY;AACnB;AAAA,EACE,WAAW;AAAA,EACX;AAAA,OAEK;AACP,SAAS,cAAc,uBAAuB;AAC9C,SAAS,wBAAwB,2BAA2B;AAE5D,SAAS,oDAAoD;AAd7D;AAAA;AAgBA,QAAM,QAAQ,GAAG;AAAA,MACf,KAAK,KAAK,WAAW,2BAA2B;AAAA,MAChD;AAAA,QACE,UAAU;AAAA,MACZ;AAAA,IACF;AAEA,QAAM,cAAc,MAAM,KAAK;AAC/B,QAAM,gBAAgB,aAAa,QAAQ,WAAW;AAEtD,QAAM,EAAE,YAAY,IAAI;AAAA,MACtB;AAAA,MACA;AAAA,IACF;AAEA,QAAM,iBAAiC;AAAA,MACrC,UAAU;AAAA,MACV;AAAA,MACA;AAAA,IACF;AAEA,QAAM,oBAAoB,IAAI,cAAc,eAAe;AAC3D,sBAAkB,IAAI,+BAA+B,MAAY;AAC/D,YAAM,SAAS,MAAM,eAAe;AAAA,QAClC;AAAA,QACA,UAAU,MAAM,KAAK;AAAA,QACrB,cAAc,EAAE,OAAO;AAAA,MACzB,CAAC;AACD,UAAI,OAAO,UAAU,CAAC,OAAO,MAAM;AACjC,cAAM,IAAI,MAAM,uBAAuB;AAAA,MACzC;AAAA,IACF,EAAC;AACD,sBAAkB,IAAI,+BAA+B,MAAY;AAC/D,YAAM,SAAS,MAAM,eAAe;AAAA,Q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BAAiB;AAC/D,wBAAoB,IAAI,eAAe,MAAY;AACjD,YAAM,aAAa,QAAQ,WAAW;AAAA,IACxC,EAAC;AAED,QAAM,uBAAuB,IAAI,cAAc,kBAAkB;AACjE,yBAAqB,IAAI,gBAAgB,MAAM;AAC7C,mDAA6C,QAAQ,WAAW;AAAA,IAClE,CAAC;AAED,aAAe,OAAO;AAAA;AACpB,cAAM,oBAAoB,IAAI;AAC9B,cAAM,kBAAkB,IAAI;AAC5B,cAAM,qBAAqB,IAAI;AAC/B,cAAM,kBAAkB,IAAI;AAAA,MAC9B;AAAA;AAEA,SAAK;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectFields.d.ts","sourceRoot":"","sources":["../src/collectFields.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAMV,MAAM,SAAS,CAAC;AAUjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"collectFields.d.ts","sourceRoot":"","sources":["../src/collectFields.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAMV,MAAM,SAAS,CAAC;AAUjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI1D,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;AAElD,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,MAAM,WAAW,gBAAgB;IAC/B,eAAe,EAAE,eAAe,CAAC;IACjC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,gBAAgB,EAC5B,eAAe,EAAE,MAAM,GACtB,gBAAgB,CAalB;AAED;;;;;;;;;GASG;AAEH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,gBAAgB,EAC5B,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,UAAU,GACrB,gBAAgB,CAuBlB"}
|
package/lib/collectFields.js
CHANGED
|
@@ -37,6 +37,7 @@ var import_values = require("./values");
|
|
|
37
37
|
var import_directives = require("./schema/directives");
|
|
38
38
|
var import_AccumulatorMap = require("./jsutils/AccumulatorMap");
|
|
39
39
|
var import_invariant = __toESM(require("invariant"));
|
|
40
|
+
var import_definition = require("./schema/definition");
|
|
40
41
|
function collectFields(exeContext, runtimeTypeName) {
|
|
41
42
|
const { operation } = exeContext;
|
|
42
43
|
const groupedFieldSet = new import_AccumulatorMap.AccumulatorMap();
|
|
@@ -87,7 +88,7 @@ function collectFieldsImpl(exeContext, runtimeTypeName, selectionSet, groupedFie
|
|
|
87
88
|
if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(
|
|
88
89
|
selection,
|
|
89
90
|
runtimeTypeName,
|
|
90
|
-
exeContext.
|
|
91
|
+
exeContext.schemaFragment
|
|
91
92
|
)) {
|
|
92
93
|
continue;
|
|
93
94
|
}
|
|
@@ -131,7 +132,7 @@ function collectFieldsImpl(exeContext, runtimeTypeName, selectionSet, groupedFie
|
|
|
131
132
|
if (fragment == null || !doesFragmentConditionMatch(
|
|
132
133
|
fragment,
|
|
133
134
|
runtimeTypeName,
|
|
134
|
-
exeContext.
|
|
135
|
+
exeContext.schemaFragment
|
|
135
136
|
)) {
|
|
136
137
|
continue;
|
|
137
138
|
}
|
|
@@ -182,7 +183,7 @@ function shouldIncludeNode(exeContext, node) {
|
|
|
182
183
|
}
|
|
183
184
|
return true;
|
|
184
185
|
}
|
|
185
|
-
function doesFragmentConditionMatch(fragment, typeName,
|
|
186
|
+
function doesFragmentConditionMatch(fragment, typeName, { definitions }) {
|
|
186
187
|
const typeConditionNode = fragment.typeCondition;
|
|
187
188
|
if (!typeConditionNode) {
|
|
188
189
|
return true;
|
|
@@ -191,8 +192,8 @@ function doesFragmentConditionMatch(fragment, typeName, schemaFragment) {
|
|
|
191
192
|
if (conditionalTypeName === typeName) {
|
|
192
193
|
return true;
|
|
193
194
|
}
|
|
194
|
-
if (
|
|
195
|
-
return
|
|
195
|
+
if ((0, import_definition.isAbstractType)(definitions, conditionalTypeName)) {
|
|
196
|
+
return (0, import_definition.isSubType)(definitions, conditionalTypeName, typeName);
|
|
196
197
|
}
|
|
197
198
|
return false;
|
|
198
199
|
}
|
package/lib/collectFields.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/collectFields.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n Kind,\n FieldNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n SelectionNode,\n SelectionSetNode,\n} from \"graphql\";\nimport { getDirectiveValues } from \"./values\";\nimport {\n GraphQLSkipDirective,\n GraphQLIncludeDirective,\n GraphQLDeferDirective,\n} from \"./schema/directives\";\n\nimport { AccumulatorMap } from \"./jsutils/AccumulatorMap\";\nimport invariant from \"invariant\";\nimport { ExecutionContext } from \"./executeWithoutSchema\";\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAQO;AACP,oBAAmC;AACnC,wBAIO;AAEP,4BAA+B;AAC/B,uBAAsB;
|
|
4
|
+
"sourcesContent": ["import {\n Kind,\n FieldNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n SelectionNode,\n SelectionSetNode,\n} from \"graphql\";\nimport { getDirectiveValues } from \"./values\";\nimport {\n GraphQLSkipDirective,\n GraphQLIncludeDirective,\n GraphQLDeferDirective,\n} from \"./schema/directives\";\n\nimport { AccumulatorMap } from \"./jsutils/AccumulatorMap\";\nimport invariant from \"invariant\";\nimport { ExecutionContext } from \"./executeWithoutSchema\";\nimport { isAbstractType, isSubType } from \"./schema/definition\";\nimport { SchemaFragment } from \"./types\";\n\nexport type FieldGroup = ReadonlyArray<FieldNode>;\n\nexport type GroupedFieldSet = Map<string, FieldGroup>;\n\nexport interface PatchFields {\n label: string | undefined;\n groupedFieldSet: GroupedFieldSet;\n}\n\nexport interface FieldsAndPatches {\n groupedFieldSet: GroupedFieldSet;\n patches: Array<PatchFields>;\n}\n\n/**\n * Given a selectionSet, collects all of the fields and returns them.\n *\n * CollectFields requires the \"runtime type\" of an object. For a field that\n * returns an Interface or Union type, the \"runtime type\" will be the actual\n * object type returned by that field.\n *\n * @internal\n */\nexport function collectFields(\n exeContext: ExecutionContext,\n runtimeTypeName: string,\n): FieldsAndPatches {\n const { operation } = exeContext;\n const groupedFieldSet = new AccumulatorMap<string, FieldNode>();\n const patches: Array<PatchFields> = [];\n collectFieldsImpl(\n exeContext,\n runtimeTypeName,\n operation.selectionSet,\n groupedFieldSet,\n patches,\n new Set(),\n );\n return { groupedFieldSet, patches };\n}\n\n/**\n * Given an array of field nodes, collects all of the subfields of the passed\n * in fields, and returns them at the end.\n *\n * CollectSubFields requires the \"return type\" of an object. For a field that\n * returns an Interface or Union type, the \"return type\" will be the actual\n * object type returned by that field.\n *\n * @internal\n */\n// eslint-disable-next-line max-params\nexport function collectSubfields(\n exeContext: ExecutionContext,\n returnTypeName: string,\n fieldGroup: FieldGroup,\n): FieldsAndPatches {\n const subGroupedFieldSet = new AccumulatorMap<string, FieldNode>();\n const visitedFragmentNames = new Set<string>();\n\n const subPatches: Array<PatchFields> = [];\n const subFieldsAndPatches = {\n groupedFieldSet: subGroupedFieldSet,\n patches: subPatches,\n };\n\n for (const node of fieldGroup) {\n if (node.selectionSet) {\n collectFieldsImpl(\n exeContext,\n returnTypeName,\n node.selectionSet,\n subGroupedFieldSet,\n subPatches,\n visitedFragmentNames,\n );\n }\n }\n return subFieldsAndPatches;\n}\n\n// eslint-disable-next-line max-params\nfunction collectFieldsImpl(\n exeContext: ExecutionContext,\n runtimeTypeName: string,\n selectionSet: SelectionSetNode,\n groupedFieldSet: AccumulatorMap<string, FieldNode>,\n patches: Array<PatchFields>,\n visitedFragmentNames: Set<string>,\n): void {\n for (const selection of selectionSet.selections) {\n switch (selection.kind) {\n case Kind.FIELD: {\n if (!shouldIncludeNode(exeContext, selection)) {\n continue;\n }\n groupedFieldSet.add(getFieldEntryKey(selection), selection);\n break;\n }\n case Kind.INLINE_FRAGMENT: {\n if (\n !shouldIncludeNode(exeContext, selection) ||\n !doesFragmentConditionMatch(\n selection,\n runtimeTypeName,\n exeContext.schemaFragment,\n )\n ) {\n continue;\n }\n\n const defer = getDeferValues(exeContext, selection);\n\n if (defer) {\n const patchFields = new AccumulatorMap<string, FieldNode>();\n collectFieldsImpl(\n exeContext,\n runtimeTypeName,\n selection.selectionSet,\n patchFields,\n patches,\n visitedFragmentNames,\n );\n patches.push({\n label: defer.label,\n groupedFieldSet: patchFields,\n });\n } else {\n collectFieldsImpl(\n exeContext,\n runtimeTypeName,\n selection.selectionSet,\n groupedFieldSet,\n patches,\n visitedFragmentNames,\n );\n }\n break;\n }\n case Kind.FRAGMENT_SPREAD: {\n const fragName = selection.name.value;\n\n if (!shouldIncludeNode(exeContext, selection)) {\n continue;\n }\n\n const defer = getDeferValues(exeContext, selection);\n if (visitedFragmentNames.has(fragName) && !defer) {\n continue;\n }\n\n const fragment = exeContext.fragments[fragName];\n if (\n fragment == null ||\n !doesFragmentConditionMatch(\n fragment,\n runtimeTypeName,\n exeContext.schemaFragment,\n )\n ) {\n continue;\n }\n\n if (!defer) {\n visitedFragmentNames.add(fragName);\n }\n\n if (defer) {\n const patchFields = new AccumulatorMap<string, FieldNode>();\n collectFieldsImpl(\n exeContext,\n runtimeTypeName,\n fragment.selectionSet,\n patchFields,\n patches,\n visitedFragmentNames,\n );\n patches.push({\n label: defer.label,\n groupedFieldSet: patchFields,\n });\n } else {\n collectFieldsImpl(\n exeContext,\n runtimeTypeName,\n fragment.selectionSet,\n groupedFieldSet,\n patches,\n visitedFragmentNames,\n );\n }\n break;\n }\n }\n }\n}\n\n/**\n * Determines if a field should be included based on the @include and @skip\n * directives, where @skip has higher precedence than @include.\n */\nfunction shouldIncludeNode(\n exeContext: ExecutionContext,\n node: SelectionNode,\n): boolean {\n if (!node.directives?.length) {\n return true;\n }\n\n const skip = getDirectiveValues(exeContext, GraphQLSkipDirective, node);\n if (skip?.if === true) {\n return false;\n }\n\n const include = getDirectiveValues(exeContext, GraphQLIncludeDirective, node);\n if (include?.if === false) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Determines if a fragment is applicable to the given type.\n */\nfunction doesFragmentConditionMatch(\n fragment: FragmentDefinitionNode | InlineFragmentNode,\n typeName: string,\n { definitions }: SchemaFragment,\n): boolean {\n const typeConditionNode = fragment.typeCondition;\n if (!typeConditionNode) {\n return true;\n }\n\n const conditionalTypeName = typeConditionNode.name.value;\n\n if (conditionalTypeName === typeName) {\n return true;\n }\n if (isAbstractType(definitions, conditionalTypeName)) {\n return isSubType(definitions, conditionalTypeName, typeName);\n }\n return false;\n}\n\n/**\n * Implements the logic to compute the key of a given field's entry\n */\nfunction getFieldEntryKey(node: FieldNode): string {\n return node.alias ? node.alias.value : node.name.value;\n}\n\n/**\n * Returns an object containing the `@defer` arguments if a field should be\n * deferred based on the experimental flag, defer directive present and\n * not disabled by the \"if\" argument.\n */\nfunction getDeferValues(\n exeContext: ExecutionContext,\n node: FragmentSpreadNode | InlineFragmentNode,\n): undefined | { label: string | undefined } {\n const defer = getDirectiveValues(exeContext, GraphQLDeferDirective, node);\n\n if (!defer) {\n return;\n }\n\n if (defer.if === false) {\n return;\n }\n\n invariant(\n exeContext.operation.operation !== \"subscription\",\n \"`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.\",\n );\n\n return {\n label: typeof defer.label === \"string\" ? defer.label : undefined,\n };\n}\n"],
|
|
5
|
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,UAAK,eAAL,mBAAiB,SAAQ;AAC5B,WAAO;AAAA,EACT;AAEA,QAAM,WAAO,kCAAmB,YAAY,wCAAsB,IAAI;AACtE,OAAI,6BAAM,QAAO,MAAM;AACrB,WAAO;AAAA,EACT;AAEA,QAAM,cAAU,kCAAmB,YAAY,2CAAyB,IAAI;AAC5E,OAAI,mCAAS,QAAO,OAAO;AACzB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAKA,SAAS,2BACP,UACA,UACA,EAAE,YAAY,GACL;AACT,QAAM,oBAAoB,SAAS;AACnC,MAAI,CAAC,mBAAmB;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,sBAAsB,kBAAkB,KAAK;AAEnD,MAAI,wBAAwB,UAAU;AACpC,WAAO;AAAA,EACT;AACA,UAAI,kCAAe,aAAa,mBAAmB,GAAG;AACpD,eAAO,6BAAU,aAAa,qBAAqB,QAAQ;AAAA,EAC7D;AACA,SAAO;AACT;AAKA,SAAS,iBAAiB,MAAyB;AACjD,SAAO,KAAK,QAAQ,KAAK,MAAM,QAAQ,KAAK,KAAK;AACnD;AAOA,SAAS,eACP,YACA,MAC2C;AAC3C,QAAM,YAAQ,kCAAmB,YAAY,yCAAuB,IAAI;AAExE,MAAI,CAAC,OAAO;AACV;AAAA,EACF;AAEA,MAAI,MAAM,OAAO,OAAO;AACtB;AAAA,EACF;AAEA,uBAAAA;AAAA,IACE,WAAW,UAAU,cAAc;AAAA,IACnC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,OAAO,MAAM,UAAU,WAAW,MAAM,QAAQ;AAAA,EACzD;AACF;",
|
|
6
6
|
"names": ["invariant"]
|
|
7
7
|
}
|
package/lib/collectFields.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "./schema/directives.mjs";
|
|
11
11
|
import { AccumulatorMap } from "./jsutils/AccumulatorMap.mjs";
|
|
12
12
|
import invariant from "invariant";
|
|
13
|
+
import { isAbstractType, isSubType } from "./schema/definition.mjs";
|
|
13
14
|
function collectFields(exeContext, runtimeTypeName) {
|
|
14
15
|
const { operation } = exeContext;
|
|
15
16
|
const groupedFieldSet = new AccumulatorMap();
|
|
@@ -60,7 +61,7 @@ function collectFieldsImpl(exeContext, runtimeTypeName, selectionSet, groupedFie
|
|
|
60
61
|
if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(
|
|
61
62
|
selection,
|
|
62
63
|
runtimeTypeName,
|
|
63
|
-
exeContext.
|
|
64
|
+
exeContext.schemaFragment
|
|
64
65
|
)) {
|
|
65
66
|
continue;
|
|
66
67
|
}
|
|
@@ -104,7 +105,7 @@ function collectFieldsImpl(exeContext, runtimeTypeName, selectionSet, groupedFie
|
|
|
104
105
|
if (fragment == null || !doesFragmentConditionMatch(
|
|
105
106
|
fragment,
|
|
106
107
|
runtimeTypeName,
|
|
107
|
-
exeContext.
|
|
108
|
+
exeContext.schemaFragment
|
|
108
109
|
)) {
|
|
109
110
|
continue;
|
|
110
111
|
}
|
|
@@ -155,7 +156,7 @@ function shouldIncludeNode(exeContext, node) {
|
|
|
155
156
|
}
|
|
156
157
|
return true;
|
|
157
158
|
}
|
|
158
|
-
function doesFragmentConditionMatch(fragment, typeName,
|
|
159
|
+
function doesFragmentConditionMatch(fragment, typeName, { definitions }) {
|
|
159
160
|
const typeConditionNode = fragment.typeCondition;
|
|
160
161
|
if (!typeConditionNode) {
|
|
161
162
|
return true;
|
|
@@ -164,8 +165,8 @@ function doesFragmentConditionMatch(fragment, typeName, schemaFragment) {
|
|
|
164
165
|
if (conditionalTypeName === typeName) {
|
|
165
166
|
return true;
|
|
166
167
|
}
|
|
167
|
-
if (
|
|
168
|
-
return
|
|
168
|
+
if (isAbstractType(definitions, conditionalTypeName)) {
|
|
169
|
+
return isSubType(definitions, conditionalTypeName, typeName);
|
|
169
170
|
}
|
|
170
171
|
return false;
|
|
171
172
|
}
|