@graphitation/supermassive 3.0.0-alpha.1 → 3.0.0-alpha.3
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 +10 -2
- package/lib/__testUtils__/execute.d.ts +13 -0
- package/lib/__testUtils__/execute.d.ts.map +1 -0
- package/lib/__testUtils__/execute.js +196 -0
- package/lib/__testUtils__/execute.js.map +7 -0
- package/lib/__testUtils__/execute.mjs +174 -0
- package/lib/__testUtils__/execute.mjs.map +7 -0
- package/lib/benchmarks/index.js +10 -19
- package/lib/benchmarks/index.js.map +3 -3
- package/lib/benchmarks/index.mjs +11 -22
- package/lib/benchmarks/index.mjs.map +2 -2
- package/lib/collectFields.d.ts +4 -9
- package/lib/collectFields.d.ts.map +1 -1
- package/lib/collectFields.js +38 -99
- package/lib/collectFields.js.map +2 -2
- package/lib/collectFields.mjs +41 -100
- 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 +7 -13
- package/lib/executeWithSchema.js.map +2 -2
- package/lib/executeWithSchema.mjs +9 -20
- package/lib/executeWithSchema.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +5 -5
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +175 -227
- package/lib/executeWithoutSchema.js.map +2 -2
- package/lib/executeWithoutSchema.mjs +176 -228
- package/lib/executeWithoutSchema.mjs.map +2 -2
- package/lib/index.d.ts +2 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -7
- package/lib/index.js.map +2 -2
- package/lib/index.mjs +0 -10
- package/lib/index.mjs.map +2 -2
- package/lib/schema/definition.d.ts +95 -0
- package/lib/schema/definition.d.ts.map +1 -0
- package/lib/schema/definition.js +77 -0
- package/lib/schema/definition.js.map +7 -0
- package/lib/schema/definition.mjs +58 -0
- package/lib/schema/definition.mjs.map +7 -0
- package/lib/schema/directives.d.ts +41 -0
- package/lib/schema/directives.d.ts.map +1 -0
- package/lib/schema/directives.js +82 -0
- package/lib/schema/directives.js.map +7 -0
- package/lib/schema/directives.mjs +65 -0
- package/lib/schema/directives.mjs.map +7 -0
- package/lib/schema/fragment.d.ts +41 -0
- package/lib/schema/fragment.d.ts.map +1 -0
- package/lib/schema/fragment.js +270 -0
- package/lib/schema/fragment.js.map +7 -0
- package/lib/schema/fragment.mjs +267 -0
- package/lib/schema/fragment.mjs.map +7 -0
- package/lib/schema/reference.d.ts +12 -0
- package/lib/schema/reference.d.ts.map +1 -0
- package/lib/schema/reference.js +137 -0
- package/lib/schema/reference.js.map +7 -0
- package/lib/schema/reference.mjs +118 -0
- package/lib/schema/reference.mjs.map +7 -0
- package/lib/schema/resolvers.d.ts +9 -0
- package/lib/schema/resolvers.d.ts.map +1 -0
- package/lib/schema/resolvers.js +47 -0
- package/lib/schema/resolvers.js.map +7 -0
- package/lib/schema/resolvers.mjs +35 -0
- package/lib/schema/resolvers.mjs.map +7 -0
- package/lib/subscribeWithSchema.d.ts +1 -1
- package/lib/subscribeWithSchema.d.ts.map +1 -1
- package/lib/subscribeWithSchema.js +7 -13
- package/lib/subscribeWithSchema.js.map +2 -2
- package/lib/subscribeWithSchema.mjs +9 -20
- package/lib/subscribeWithSchema.mjs.map +2 -2
- package/lib/types.d.ts +10 -24
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +2 -2
- package/lib/types.mjs.map +2 -2
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts +9 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts.map +1 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.js +303 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.js.map +7 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs +317 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs.map +7 -0
- package/lib/{supermassive-ast → utilities}/annotateDocumentGraphQLTransform.d.ts +1 -1
- package/lib/utilities/annotateDocumentGraphQLTransform.d.ts.map +1 -0
- package/lib/{supermassive-ast → utilities}/annotateDocumentGraphQLTransform.js +3 -3
- package/lib/utilities/annotateDocumentGraphQLTransform.js.map +7 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.mjs +17 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.mjs.map +7 -0
- package/lib/utilities/coerceInputValue.d.ts +10 -0
- package/lib/utilities/coerceInputValue.d.ts.map +1 -0
- package/lib/utilities/coerceInputValue.js +181 -0
- package/lib/utilities/coerceInputValue.js.map +7 -0
- package/lib/utilities/coerceInputValue.mjs +167 -0
- package/lib/utilities/coerceInputValue.mjs.map +7 -0
- package/lib/utilities/decodeASTSchema.d.ts +7 -0
- package/lib/utilities/decodeASTSchema.d.ts.map +1 -0
- package/lib/utilities/decodeASTSchema.js +243 -0
- package/lib/utilities/decodeASTSchema.js.map +7 -0
- package/lib/utilities/decodeASTSchema.mjs +242 -0
- package/lib/utilities/decodeASTSchema.mjs.map +7 -0
- package/lib/utilities/encodeASTSchema.d.ts +4 -0
- package/lib/utilities/encodeASTSchema.d.ts.map +1 -0
- package/lib/utilities/encodeASTSchema.js +122 -0
- package/lib/utilities/encodeASTSchema.js.map +7 -0
- package/lib/utilities/encodeASTSchema.mjs +105 -0
- package/lib/utilities/encodeASTSchema.mjs.map +7 -0
- package/lib/utilities/getSchemaFragment.d.ts +4 -0
- package/lib/utilities/getSchemaFragment.d.ts.map +1 -0
- package/lib/utilities/getSchemaFragment.js +38 -0
- package/lib/utilities/getSchemaFragment.js.map +7 -0
- package/lib/utilities/getSchemaFragment.mjs +22 -0
- package/lib/utilities/getSchemaFragment.mjs.map +7 -0
- package/lib/utilities/makeReadableErrorPath.d.ts +3 -0
- package/lib/utilities/makeReadableErrorPath.d.ts.map +1 -0
- package/lib/utilities/makeReadableErrorPath.js +47 -0
- package/lib/utilities/makeReadableErrorPath.js.map +7 -0
- package/lib/utilities/makeReadableErrorPath.mjs +28 -0
- package/lib/utilities/makeReadableErrorPath.mjs.map +7 -0
- package/lib/utilities/mergeDefinitions.d.ts +8 -0
- package/lib/utilities/mergeDefinitions.d.ts.map +1 -0
- package/lib/utilities/mergeDefinitions.js +126 -0
- package/lib/utilities/mergeDefinitions.js.map +7 -0
- package/lib/utilities/mergeDefinitions.mjs +114 -0
- package/lib/utilities/mergeDefinitions.mjs.map +7 -0
- package/lib/utilities/typeNameFromAST.d.ts +1 -1
- package/lib/utilities/typeNameFromAST.d.ts.map +1 -1
- package/lib/utilities/typeNameFromAST.js.map +2 -2
- package/lib/utilities/typeNameFromAST.mjs.map +2 -2
- package/lib/utilities/valueFromAST.d.ts +27 -0
- package/lib/utilities/valueFromAST.d.ts.map +1 -0
- package/lib/utilities/valueFromAST.js +139 -0
- package/lib/utilities/valueFromAST.js.map +7 -0
- package/lib/utilities/valueFromAST.mjs +125 -0
- package/lib/utilities/valueFromAST.mjs.map +7 -0
- package/lib/utilities/valueFromASTUntyped.d.ts +21 -0
- package/lib/utilities/valueFromASTUntyped.d.ts.map +1 -0
- package/lib/utilities/valueFromASTUntyped.js +51 -0
- package/lib/utilities/valueFromASTUntyped.js.map +7 -0
- package/lib/utilities/valueFromASTUntyped.mjs +32 -0
- package/lib/utilities/valueFromASTUntyped.mjs.map +7 -0
- package/lib/values.d.ts +8 -12
- package/lib/values.d.ts.map +1 -1
- package/lib/values.js +75 -63
- package/lib/values.js.map +2 -2
- package/lib/values.mjs +77 -71
- package/lib/values.mjs.map +2 -2
- package/package.json +8 -6
- package/lib/definition.d.ts +0 -7
- package/lib/definition.d.ts.map +0 -1
- package/lib/definition.js +0 -59
- package/lib/definition.js.map +0 -7
- package/lib/definition.mjs +0 -40
- package/lib/definition.mjs.map +0 -7
- package/lib/directives.d.ts +0 -8
- package/lib/directives.d.ts.map +0 -1
- package/lib/directives.js +0 -47
- package/lib/directives.js.map +0 -7
- package/lib/directives.mjs +0 -37
- package/lib/directives.mjs.map +0 -7
- package/lib/extractImplicitTypesRuntime.d.ts +0 -4
- package/lib/extractImplicitTypesRuntime.d.ts.map +0 -1
- package/lib/extractImplicitTypesRuntime.js +0 -123
- package/lib/extractImplicitTypesRuntime.js.map +0 -7
- package/lib/extractImplicitTypesRuntime.mjs +0 -114
- package/lib/extractImplicitTypesRuntime.mjs.map +0 -7
- package/lib/supermassive-ast/TypedAST.d.ts +0 -370
- package/lib/supermassive-ast/TypedAST.d.ts.map +0 -1
- package/lib/supermassive-ast/TypedAST.js +0 -29
- package/lib/supermassive-ast/TypedAST.js.map +0 -7
- package/lib/supermassive-ast/TypedAST.mjs +0 -10
- package/lib/supermassive-ast/TypedAST.mjs.map +0 -7
- package/lib/supermassive-ast/addTypesToRequestDocument.d.ts +0 -56
- package/lib/supermassive-ast/addTypesToRequestDocument.d.ts.map +0 -1
- package/lib/supermassive-ast/addTypesToRequestDocument.js +0 -473
- package/lib/supermassive-ast/addTypesToRequestDocument.js.map +0 -7
- package/lib/supermassive-ast/addTypesToRequestDocument.mjs +0 -463
- package/lib/supermassive-ast/addTypesToRequestDocument.mjs.map +0 -7
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.d.ts.map +0 -1
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.js.map +0 -7
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.mjs +0 -17
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.mjs.map +0 -7
- package/lib/supermassive-ast/directives.d.ts +0 -36
- package/lib/supermassive-ast/directives.d.ts.map +0 -1
- package/lib/supermassive-ast/directives.js +0 -165
- package/lib/supermassive-ast/directives.js.map +0 -7
- package/lib/supermassive-ast/directives.mjs +0 -153
- package/lib/supermassive-ast/directives.mjs.map +0 -7
- package/lib/supermassive-ast/index.d.ts +0 -6
- package/lib/supermassive-ast/index.d.ts.map +0 -1
- package/lib/supermassive-ast/index.js +0 -37
- package/lib/supermassive-ast/index.js.map +0 -7
- package/lib/supermassive-ast/index.mjs +0 -27
- package/lib/supermassive-ast/index.mjs.map +0 -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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,mBAAmB;AAC1B,OAAO,YAAY;AACnB,OAAO,eAAe;AACtB,OAAO,YAAY;AACnB;AAAA,EACE
|
|
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/addMinimalViableSchemaToRequestDocument\";\n\nconst query = fs.readFileSync(\n path.join(__dirname, \"./fixtures/query1.graphql\"),\n {\n encoding: \"utf-8\",\n },\n);\n\nconst parsedQuery = parse(query);\n\nconst compiledQuery = compileQuery(schema, parsedQuery);\n\nconst schemaFragment = extractMinimalViableSchemaForRequestDocument(\n schema,\n parsedQuery,\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 resolvers: resolvers as UserResolvers,\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,OA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
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/collectFields.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { FieldNode
|
|
2
|
-
import
|
|
3
|
-
import { Resolvers } from "./types";
|
|
1
|
+
import { FieldNode } from "graphql";
|
|
2
|
+
import { ExecutionContext } from "./executeWithoutSchema";
|
|
4
3
|
export type FieldGroup = ReadonlyArray<FieldNode>;
|
|
5
4
|
export type GroupedFieldSet = Map<string, FieldGroup>;
|
|
6
5
|
export interface PatchFields {
|
|
@@ -20,9 +19,7 @@ export interface FieldsAndPatches {
|
|
|
20
19
|
*
|
|
21
20
|
* @internal
|
|
22
21
|
*/
|
|
23
|
-
export declare function collectFields(
|
|
24
|
-
[variable: string]: unknown;
|
|
25
|
-
}, runtimeTypeName: string, operation: OperationDefinitionNode): FieldsAndPatches;
|
|
22
|
+
export declare function collectFields(exeContext: ExecutionContext, runtimeTypeName: string): FieldsAndPatches;
|
|
26
23
|
/**
|
|
27
24
|
* Given an array of field nodes, collects all of the subfields of the passed
|
|
28
25
|
* in fields, and returns them at the end.
|
|
@@ -33,7 +30,5 @@ export declare function collectFields(resolvers: Resolvers, fragments: ObjMap<Fr
|
|
|
33
30
|
*
|
|
34
31
|
* @internal
|
|
35
32
|
*/
|
|
36
|
-
export declare function collectSubfields(
|
|
37
|
-
[variable: string]: unknown;
|
|
38
|
-
}, operation: OperationDefinitionNode, returnTypeName: string, fieldGroup: FieldGroup): FieldsAndPatches;
|
|
33
|
+
export declare function collectSubfields(exeContext: ExecutionContext, returnTypeName: string, fieldGroup: FieldGroup): FieldsAndPatches;
|
|
39
34
|
//# sourceMappingURL=collectFields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectFields.d.ts","sourceRoot":"","sources":["../src/collectFields.ts"],"names":[],"mappings":"
|
|
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;AAG1D,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
|
@@ -34,19 +34,15 @@ __export(collectFields_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(collectFields_exports);
|
|
35
35
|
var import_graphql = require("graphql");
|
|
36
36
|
var import_values = require("./values");
|
|
37
|
-
var import_directives = require("./directives");
|
|
38
|
-
var import_typeNameFromAST = require("./utilities/typeNameFromAST");
|
|
39
|
-
var import_definition = require("./definition");
|
|
37
|
+
var import_directives = require("./schema/directives");
|
|
40
38
|
var import_AccumulatorMap = require("./jsutils/AccumulatorMap");
|
|
41
39
|
var import_invariant = __toESM(require("invariant"));
|
|
42
|
-
function collectFields(
|
|
40
|
+
function collectFields(exeContext, runtimeTypeName) {
|
|
41
|
+
const { operation } = exeContext;
|
|
43
42
|
const groupedFieldSet = new import_AccumulatorMap.AccumulatorMap();
|
|
44
43
|
const patches = [];
|
|
45
44
|
collectFieldsImpl(
|
|
46
|
-
|
|
47
|
-
fragments,
|
|
48
|
-
variableValues,
|
|
49
|
-
operation,
|
|
45
|
+
exeContext,
|
|
50
46
|
runtimeTypeName,
|
|
51
47
|
operation.selectionSet,
|
|
52
48
|
groupedFieldSet,
|
|
@@ -55,7 +51,7 @@ function collectFields(resolvers, fragments, variableValues, runtimeTypeName, op
|
|
|
55
51
|
);
|
|
56
52
|
return { groupedFieldSet, patches };
|
|
57
53
|
}
|
|
58
|
-
function collectSubfields(
|
|
54
|
+
function collectSubfields(exeContext, returnTypeName, fieldGroup) {
|
|
59
55
|
const subGroupedFieldSet = new import_AccumulatorMap.AccumulatorMap();
|
|
60
56
|
const visitedFragmentNames = /* @__PURE__ */ new Set();
|
|
61
57
|
const subPatches = [];
|
|
@@ -66,10 +62,7 @@ function collectSubfields(resolvers, fragments, variableValues, operation, retur
|
|
|
66
62
|
for (const node of fieldGroup) {
|
|
67
63
|
if (node.selectionSet) {
|
|
68
64
|
collectFieldsImpl(
|
|
69
|
-
|
|
70
|
-
fragments,
|
|
71
|
-
variableValues,
|
|
72
|
-
operation,
|
|
65
|
+
exeContext,
|
|
73
66
|
returnTypeName,
|
|
74
67
|
node.selectionSet,
|
|
75
68
|
subGroupedFieldSet,
|
|
@@ -80,33 +73,29 @@ function collectSubfields(resolvers, fragments, variableValues, operation, retur
|
|
|
80
73
|
}
|
|
81
74
|
return subFieldsAndPatches;
|
|
82
75
|
}
|
|
83
|
-
function collectFieldsImpl(
|
|
76
|
+
function collectFieldsImpl(exeContext, runtimeTypeName, selectionSet, groupedFieldSet, patches, visitedFragmentNames) {
|
|
84
77
|
for (const selection of selectionSet.selections) {
|
|
85
78
|
switch (selection.kind) {
|
|
86
79
|
case import_graphql.Kind.FIELD: {
|
|
87
|
-
if (!shouldIncludeNode(
|
|
80
|
+
if (!shouldIncludeNode(exeContext, selection)) {
|
|
88
81
|
continue;
|
|
89
82
|
}
|
|
90
83
|
groupedFieldSet.add(getFieldEntryKey(selection), selection);
|
|
91
84
|
break;
|
|
92
85
|
}
|
|
93
86
|
case import_graphql.Kind.INLINE_FRAGMENT: {
|
|
94
|
-
if (!shouldIncludeNode(
|
|
87
|
+
if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(
|
|
88
|
+
selection,
|
|
89
|
+
runtimeTypeName,
|
|
90
|
+
exeContext.schemaTypes
|
|
91
|
+
)) {
|
|
95
92
|
continue;
|
|
96
93
|
}
|
|
97
|
-
const defer = getDeferValues(
|
|
98
|
-
resolvers,
|
|
99
|
-
operation,
|
|
100
|
-
variableValues,
|
|
101
|
-
selection
|
|
102
|
-
);
|
|
94
|
+
const defer = getDeferValues(exeContext, selection);
|
|
103
95
|
if (defer) {
|
|
104
96
|
const patchFields = new import_AccumulatorMap.AccumulatorMap();
|
|
105
97
|
collectFieldsImpl(
|
|
106
|
-
|
|
107
|
-
fragments,
|
|
108
|
-
variableValues,
|
|
109
|
-
operation,
|
|
98
|
+
exeContext,
|
|
110
99
|
runtimeTypeName,
|
|
111
100
|
selection.selectionSet,
|
|
112
101
|
patchFields,
|
|
@@ -119,10 +108,7 @@ function collectFieldsImpl(resolvers, fragments, variableValues, operation, runt
|
|
|
119
108
|
});
|
|
120
109
|
} else {
|
|
121
110
|
collectFieldsImpl(
|
|
122
|
-
|
|
123
|
-
fragments,
|
|
124
|
-
variableValues,
|
|
125
|
-
operation,
|
|
111
|
+
exeContext,
|
|
126
112
|
runtimeTypeName,
|
|
127
113
|
selection.selectionSet,
|
|
128
114
|
groupedFieldSet,
|
|
@@ -134,20 +120,19 @@ function collectFieldsImpl(resolvers, fragments, variableValues, operation, runt
|
|
|
134
120
|
}
|
|
135
121
|
case import_graphql.Kind.FRAGMENT_SPREAD: {
|
|
136
122
|
const fragName = selection.name.value;
|
|
137
|
-
if (!shouldIncludeNode(
|
|
123
|
+
if (!shouldIncludeNode(exeContext, selection)) {
|
|
138
124
|
continue;
|
|
139
125
|
}
|
|
140
|
-
const defer = getDeferValues(
|
|
141
|
-
resolvers,
|
|
142
|
-
operation,
|
|
143
|
-
variableValues,
|
|
144
|
-
selection
|
|
145
|
-
);
|
|
126
|
+
const defer = getDeferValues(exeContext, selection);
|
|
146
127
|
if (visitedFragmentNames.has(fragName) && !defer) {
|
|
147
128
|
continue;
|
|
148
129
|
}
|
|
149
|
-
const fragment = fragments[fragName];
|
|
150
|
-
if (fragment == null || !doesFragmentConditionMatch(
|
|
130
|
+
const fragment = exeContext.fragments[fragName];
|
|
131
|
+
if (fragment == null || !doesFragmentConditionMatch(
|
|
132
|
+
fragment,
|
|
133
|
+
runtimeTypeName,
|
|
134
|
+
exeContext.schemaTypes
|
|
135
|
+
)) {
|
|
151
136
|
continue;
|
|
152
137
|
}
|
|
153
138
|
if (!defer) {
|
|
@@ -156,10 +141,7 @@ function collectFieldsImpl(resolvers, fragments, variableValues, operation, runt
|
|
|
156
141
|
if (defer) {
|
|
157
142
|
const patchFields = new import_AccumulatorMap.AccumulatorMap();
|
|
158
143
|
collectFieldsImpl(
|
|
159
|
-
|
|
160
|
-
fragments,
|
|
161
|
-
variableValues,
|
|
162
|
-
operation,
|
|
144
|
+
exeContext,
|
|
163
145
|
runtimeTypeName,
|
|
164
146
|
fragment.selectionSet,
|
|
165
147
|
patchFields,
|
|
@@ -172,10 +154,7 @@ function collectFieldsImpl(resolvers, fragments, variableValues, operation, runt
|
|
|
172
154
|
});
|
|
173
155
|
} else {
|
|
174
156
|
collectFieldsImpl(
|
|
175
|
-
|
|
176
|
-
fragments,
|
|
177
|
-
variableValues,
|
|
178
|
-
operation,
|
|
157
|
+
exeContext,
|
|
179
158
|
runtimeTypeName,
|
|
180
159
|
fragment.selectionSet,
|
|
181
160
|
groupedFieldSet,
|
|
@@ -188,80 +167,40 @@ function collectFieldsImpl(resolvers, fragments, variableValues, operation, runt
|
|
|
188
167
|
}
|
|
189
168
|
}
|
|
190
169
|
}
|
|
191
|
-
function shouldIncludeNode(
|
|
170
|
+
function shouldIncludeNode(exeContext, node) {
|
|
192
171
|
var _a;
|
|
193
172
|
if (!((_a = node.directives) == null ? void 0 : _a.length)) {
|
|
194
173
|
return true;
|
|
195
174
|
}
|
|
196
|
-
const skip = (0, import_values.getDirectiveValues)(
|
|
197
|
-
import_directives.GraphQLSkipDirective,
|
|
198
|
-
node,
|
|
199
|
-
resolvers,
|
|
200
|
-
variableValues
|
|
201
|
-
);
|
|
175
|
+
const skip = (0, import_values.getDirectiveValues)(exeContext, import_directives.GraphQLSkipDirective, node);
|
|
202
176
|
if ((skip == null ? void 0 : skip.if) === true) {
|
|
203
177
|
return false;
|
|
204
178
|
}
|
|
205
|
-
const include = (0, import_values.getDirectiveValues)(
|
|
206
|
-
import_directives.GraphQLIncludeDirective,
|
|
207
|
-
node,
|
|
208
|
-
resolvers,
|
|
209
|
-
variableValues
|
|
210
|
-
);
|
|
179
|
+
const include = (0, import_values.getDirectiveValues)(exeContext, import_directives.GraphQLIncludeDirective, node);
|
|
211
180
|
if ((include == null ? void 0 : include.if) === false) {
|
|
212
181
|
return false;
|
|
213
182
|
}
|
|
214
183
|
return true;
|
|
215
184
|
}
|
|
216
|
-
function doesFragmentConditionMatch(fragment, typeName,
|
|
185
|
+
function doesFragmentConditionMatch(fragment, typeName, schemaFragment) {
|
|
217
186
|
const typeConditionNode = fragment.typeCondition;
|
|
218
187
|
if (!typeConditionNode) {
|
|
219
188
|
return true;
|
|
220
189
|
}
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
190
|
+
const conditionalTypeName = typeConditionNode.name.value;
|
|
191
|
+
if (conditionalTypeName === typeName) {
|
|
223
192
|
return true;
|
|
224
193
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
function getSubTypes(resolvers, abstractTypes, conditionalType) {
|
|
229
|
-
const resolver = resolvers[conditionalType];
|
|
230
|
-
if ((0, import_definition.isInterfaceResolverType)(resolver)) {
|
|
231
|
-
const result = resolver.__implementedBy.reduce(
|
|
232
|
-
(acc, item) => {
|
|
233
|
-
if (!abstractTypes.has(item)) {
|
|
234
|
-
const newTypes = /* @__PURE__ */ new Set([...abstractTypes, item]);
|
|
235
|
-
acc.push(...abstractTypes, ...getSubTypes(resolvers, newTypes, item));
|
|
236
|
-
}
|
|
237
|
-
return acc;
|
|
238
|
-
},
|
|
239
|
-
[]
|
|
240
|
-
);
|
|
241
|
-
return /* @__PURE__ */ new Set([...result]);
|
|
194
|
+
if (schemaFragment.isAbstractType(conditionalTypeName)) {
|
|
195
|
+
return schemaFragment.isSubType(conditionalTypeName, typeName);
|
|
242
196
|
}
|
|
243
|
-
|
|
244
|
-
const result = resolver.__types.reduce((acc, item) => {
|
|
245
|
-
if (!abstractTypes.has(item)) {
|
|
246
|
-
const newTypes = /* @__PURE__ */ new Set([...abstractTypes, item]);
|
|
247
|
-
acc.push(...abstractTypes, ...getSubTypes(resolvers, newTypes, item));
|
|
248
|
-
}
|
|
249
|
-
return acc;
|
|
250
|
-
}, []);
|
|
251
|
-
return /* @__PURE__ */ new Set([...result]);
|
|
252
|
-
}
|
|
253
|
-
return abstractTypes;
|
|
197
|
+
return false;
|
|
254
198
|
}
|
|
255
199
|
function getFieldEntryKey(node) {
|
|
256
200
|
return node.alias ? node.alias.value : node.name.value;
|
|
257
201
|
}
|
|
258
|
-
function getDeferValues(
|
|
259
|
-
const defer = (0, import_values.getDirectiveValues)(
|
|
260
|
-
import_directives.GraphQLDeferDirective,
|
|
261
|
-
node,
|
|
262
|
-
resolvers,
|
|
263
|
-
variableValues
|
|
264
|
-
);
|
|
202
|
+
function getDeferValues(exeContext, node) {
|
|
203
|
+
const defer = (0, import_values.getDirectiveValues)(exeContext, import_directives.GraphQLDeferDirective, node);
|
|
265
204
|
if (!defer) {
|
|
266
205
|
return;
|
|
267
206
|
}
|
|
@@ -269,7 +208,7 @@ function getDeferValues(resolvers, operation, variableValues, node) {
|
|
|
269
208
|
return;
|
|
270
209
|
}
|
|
271
210
|
(0, import_invariant.default)(
|
|
272
|
-
operation.operation !== "subscription",
|
|
211
|
+
exeContext.operation.operation !== "subscription",
|
|
273
212
|
"`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`."
|
|
274
213
|
);
|
|
275
214
|
return {
|
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 { Kind } from \"graphql\";\nimport {\n FieldNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n OperationDefinitionNode,\n SelectionNode,\n SelectionSetNode,\n} from \"./supermassive-ast\";\nimport type { ObjMap } from \"./jsutils/ObjMap\";\nimport { getDirectiveValues } from \"./values\";\nimport {\n GraphQLSkipDirective,\n GraphQLIncludeDirective,\n GraphQLDeferDirective,\n} from \"./directives\";\nimport { typeNameFromAST } from \"./utilities/typeNameFromAST\";\nimport { isUnionResolverType, isInterfaceResolverType } from \"./definition\";\n\nimport { Resolvers } from \"./types\";\n\nimport { AccumulatorMap } from \"./jsutils/AccumulatorMap\";\nimport invariant from \"invariant\";\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 resolvers: Resolvers,\n fragments: ObjMap<FragmentDefinitionNode>,\n variableValues: { [variable: string]: unknown },\n runtimeTypeName: string,\n operation: OperationDefinitionNode,\n): FieldsAndPatches {\n const groupedFieldSet = new AccumulatorMap<string, FieldNode>();\n const patches: Array<PatchFields> = [];\n collectFieldsImpl(\n resolvers,\n fragments,\n variableValues,\n operation,\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 resolvers: Resolvers,\n fragments: ObjMap<FragmentDefinitionNode>,\n variableValues: { [variable: string]: unknown },\n operation: OperationDefinitionNode,\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 resolvers,\n fragments,\n variableValues,\n operation,\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 resolvers: Resolvers,\n fragments: ObjMap<FragmentDefinitionNode>,\n variableValues: { [variable: string]: unknown },\n operation: OperationDefinitionNode,\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(resolvers, variableValues, selection)) {\n continue;\n }\n groupedFieldSet.add(getFieldEntryKey(selection), selection);\n break;\n }\n case Kind.INLINE_FRAGMENT: {\n if (\n !shouldIncludeNode(resolvers, variableValues, selection) ||\n !doesFragmentConditionMatch(selection, runtimeTypeName, resolvers)\n ) {\n continue;\n }\n\n const defer = getDeferValues(\n resolvers,\n operation,\n variableValues,\n selection,\n );\n\n if (defer) {\n const patchFields = new AccumulatorMap<string, FieldNode>();\n collectFieldsImpl(\n resolvers,\n fragments,\n variableValues,\n operation,\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 resolvers,\n fragments,\n variableValues,\n operation,\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(resolvers, variableValues, selection)) {\n continue;\n }\n\n const defer = getDeferValues(\n resolvers,\n operation,\n variableValues,\n selection,\n );\n if (visitedFragmentNames.has(fragName) && !defer) {\n continue;\n }\n\n const fragment = fragments[fragName];\n if (\n fragment == null ||\n !doesFragmentConditionMatch(fragment, runtimeTypeName, resolvers)\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 resolvers,\n fragments,\n variableValues,\n operation,\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 resolvers,\n fragments,\n variableValues,\n operation,\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 resolvers: Resolvers,\n variableValues: { [variable: string]: unknown },\n node: SelectionNode,\n): boolean {\n if (!node.directives?.length) {\n return true;\n }\n\n const skip = getDirectiveValues(\n GraphQLSkipDirective,\n node as SelectionNode,\n resolvers,\n variableValues,\n );\n if (skip?.if === true) {\n return false;\n }\n\n const include = getDirectiveValues(\n GraphQLIncludeDirective,\n node as SelectionNode,\n resolvers,\n variableValues,\n );\n\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 resolvers: Resolvers,\n): boolean {\n const typeConditionNode = fragment.typeCondition;\n if (!typeConditionNode) {\n return true;\n }\n\n const conditionalType = typeNameFromAST(typeConditionNode);\n\n if (conditionalType === typeName) {\n return true;\n }\n\n const subTypes = getSubTypes(resolvers, new Set(), conditionalType);\n\n return subTypes.has(typeName);\n}\n\nfunction getSubTypes(\n resolvers: Resolvers,\n abstractTypes: Set<string>,\n conditionalType: string,\n): Set<string> {\n const resolver = resolvers[conditionalType];\n if (isInterfaceResolverType(resolver)) {\n const result = resolver.__implementedBy.reduce(\n (acc: string[], item: string) => {\n if (!abstractTypes.has(item)) {\n const newTypes = new Set([...abstractTypes, item]);\n\n acc.push(...abstractTypes, ...getSubTypes(resolvers, newTypes, item));\n }\n return acc;\n },\n [],\n );\n\n return new Set([...result]);\n }\n\n if (isUnionResolverType(resolver)) {\n const result = resolver.__types.reduce((acc: string[], item: string) => {\n if (!abstractTypes.has(item)) {\n const newTypes = new Set([...abstractTypes, item]);\n\n acc.push(...abstractTypes, ...getSubTypes(resolvers, newTypes, item));\n }\n return acc;\n }, []);\n\n return new Set([...result]);\n }\n\n return abstractTypes;\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 resolvers: Resolvers,\n operation: OperationDefinitionNode,\n variableValues: { [variable: string]: unknown },\n node: FragmentSpreadNode | InlineFragmentNode,\n): undefined | { label: string | undefined } {\n const defer = getDirectiveValues(\n GraphQLDeferDirective,\n node,\n resolvers,\n variableValues,\n );\n\n if (!defer) {\n return;\n }\n\n if (defer.if === false) {\n return;\n }\n\n invariant(\n 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
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
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 { SchemaFragment } from \"./schema/fragment\";\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.schemaTypes,\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.schemaTypes,\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 // resolvers: Resolvers,\n schemaFragment: 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 (schemaFragment.isAbstractType(conditionalTypeName)) {\n return schemaFragment.isSubType(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
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAQO;AACP,oBAAmC;AACnC,wBAIO;AAEP,4BAA+B;AAC/B,uBAAsB;AA2Bf,SAAS,cACd,YACA,iBACkB;AAClB,QAAM,EAAE,UAAU,IAAI;AACtB,QAAM,kBAAkB,IAAI,qCAAkC;AAC9D,QAAM,UAA8B,CAAC;AACrC;AAAA,IACE;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,oBAAI,IAAI;AAAA,EACV;AACA,SAAO,EAAE,iBAAiB,QAAQ;AACpC;AAaO,SAAS,iBACd,YACA,gBACA,YACkB;AAClB,QAAM,qBAAqB,IAAI,qCAAkC;AACjE,QAAM,uBAAuB,oBAAI,IAAY;AAE7C,QAAM,aAAiC,CAAC;AACxC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,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
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
// src/collectFields.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Kind
|
|
4
|
+
} from "graphql";
|
|
3
5
|
import { getDirectiveValues } from "./values.mjs";
|
|
4
6
|
import {
|
|
5
7
|
GraphQLSkipDirective,
|
|
6
8
|
GraphQLIncludeDirective,
|
|
7
9
|
GraphQLDeferDirective
|
|
8
|
-
} from "./directives.mjs";
|
|
9
|
-
import { typeNameFromAST } from "./utilities/typeNameFromAST.mjs";
|
|
10
|
-
import { isUnionResolverType, isInterfaceResolverType } from "./definition.mjs";
|
|
10
|
+
} from "./schema/directives.mjs";
|
|
11
11
|
import { AccumulatorMap } from "./jsutils/AccumulatorMap.mjs";
|
|
12
12
|
import invariant from "invariant";
|
|
13
|
-
function collectFields(
|
|
13
|
+
function collectFields(exeContext, runtimeTypeName) {
|
|
14
|
+
const { operation } = exeContext;
|
|
14
15
|
const groupedFieldSet = new AccumulatorMap();
|
|
15
16
|
const patches = [];
|
|
16
17
|
collectFieldsImpl(
|
|
17
|
-
|
|
18
|
-
fragments,
|
|
19
|
-
variableValues,
|
|
20
|
-
operation,
|
|
18
|
+
exeContext,
|
|
21
19
|
runtimeTypeName,
|
|
22
20
|
operation.selectionSet,
|
|
23
21
|
groupedFieldSet,
|
|
@@ -26,7 +24,7 @@ function collectFields(resolvers, fragments, variableValues, runtimeTypeName, op
|
|
|
26
24
|
);
|
|
27
25
|
return { groupedFieldSet, patches };
|
|
28
26
|
}
|
|
29
|
-
function collectSubfields(
|
|
27
|
+
function collectSubfields(exeContext, returnTypeName, fieldGroup) {
|
|
30
28
|
const subGroupedFieldSet = new AccumulatorMap();
|
|
31
29
|
const visitedFragmentNames = /* @__PURE__ */ new Set();
|
|
32
30
|
const subPatches = [];
|
|
@@ -37,10 +35,7 @@ function collectSubfields(resolvers, fragments, variableValues, operation, retur
|
|
|
37
35
|
for (const node of fieldGroup) {
|
|
38
36
|
if (node.selectionSet) {
|
|
39
37
|
collectFieldsImpl(
|
|
40
|
-
|
|
41
|
-
fragments,
|
|
42
|
-
variableValues,
|
|
43
|
-
operation,
|
|
38
|
+
exeContext,
|
|
44
39
|
returnTypeName,
|
|
45
40
|
node.selectionSet,
|
|
46
41
|
subGroupedFieldSet,
|
|
@@ -51,33 +46,29 @@ function collectSubfields(resolvers, fragments, variableValues, operation, retur
|
|
|
51
46
|
}
|
|
52
47
|
return subFieldsAndPatches;
|
|
53
48
|
}
|
|
54
|
-
function collectFieldsImpl(
|
|
49
|
+
function collectFieldsImpl(exeContext, runtimeTypeName, selectionSet, groupedFieldSet, patches, visitedFragmentNames) {
|
|
55
50
|
for (const selection of selectionSet.selections) {
|
|
56
51
|
switch (selection.kind) {
|
|
57
52
|
case Kind.FIELD: {
|
|
58
|
-
if (!shouldIncludeNode(
|
|
53
|
+
if (!shouldIncludeNode(exeContext, selection)) {
|
|
59
54
|
continue;
|
|
60
55
|
}
|
|
61
56
|
groupedFieldSet.add(getFieldEntryKey(selection), selection);
|
|
62
57
|
break;
|
|
63
58
|
}
|
|
64
59
|
case Kind.INLINE_FRAGMENT: {
|
|
65
|
-
if (!shouldIncludeNode(
|
|
60
|
+
if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(
|
|
61
|
+
selection,
|
|
62
|
+
runtimeTypeName,
|
|
63
|
+
exeContext.schemaTypes
|
|
64
|
+
)) {
|
|
66
65
|
continue;
|
|
67
66
|
}
|
|
68
|
-
const defer = getDeferValues(
|
|
69
|
-
resolvers,
|
|
70
|
-
operation,
|
|
71
|
-
variableValues,
|
|
72
|
-
selection
|
|
73
|
-
);
|
|
67
|
+
const defer = getDeferValues(exeContext, selection);
|
|
74
68
|
if (defer) {
|
|
75
69
|
const patchFields = new AccumulatorMap();
|
|
76
70
|
collectFieldsImpl(
|
|
77
|
-
|
|
78
|
-
fragments,
|
|
79
|
-
variableValues,
|
|
80
|
-
operation,
|
|
71
|
+
exeContext,
|
|
81
72
|
runtimeTypeName,
|
|
82
73
|
selection.selectionSet,
|
|
83
74
|
patchFields,
|
|
@@ -90,10 +81,7 @@ function collectFieldsImpl(resolvers, fragments, variableValues, operation, runt
|
|
|
90
81
|
});
|
|
91
82
|
} else {
|
|
92
83
|
collectFieldsImpl(
|
|
93
|
-
|
|
94
|
-
fragments,
|
|
95
|
-
variableValues,
|
|
96
|
-
operation,
|
|
84
|
+
exeContext,
|
|
97
85
|
runtimeTypeName,
|
|
98
86
|
selection.selectionSet,
|
|
99
87
|
groupedFieldSet,
|
|
@@ -105,20 +93,19 @@ function collectFieldsImpl(resolvers, fragments, variableValues, operation, runt
|
|
|
105
93
|
}
|
|
106
94
|
case Kind.FRAGMENT_SPREAD: {
|
|
107
95
|
const fragName = selection.name.value;
|
|
108
|
-
if (!shouldIncludeNode(
|
|
96
|
+
if (!shouldIncludeNode(exeContext, selection)) {
|
|
109
97
|
continue;
|
|
110
98
|
}
|
|
111
|
-
const defer = getDeferValues(
|
|
112
|
-
resolvers,
|
|
113
|
-
operation,
|
|
114
|
-
variableValues,
|
|
115
|
-
selection
|
|
116
|
-
);
|
|
99
|
+
const defer = getDeferValues(exeContext, selection);
|
|
117
100
|
if (visitedFragmentNames.has(fragName) && !defer) {
|
|
118
101
|
continue;
|
|
119
102
|
}
|
|
120
|
-
const fragment = fragments[fragName];
|
|
121
|
-
if (fragment == null || !doesFragmentConditionMatch(
|
|
103
|
+
const fragment = exeContext.fragments[fragName];
|
|
104
|
+
if (fragment == null || !doesFragmentConditionMatch(
|
|
105
|
+
fragment,
|
|
106
|
+
runtimeTypeName,
|
|
107
|
+
exeContext.schemaTypes
|
|
108
|
+
)) {
|
|
122
109
|
continue;
|
|
123
110
|
}
|
|
124
111
|
if (!defer) {
|
|
@@ -127,10 +114,7 @@ function collectFieldsImpl(resolvers, fragments, variableValues, operation, runt
|
|
|
127
114
|
if (defer) {
|
|
128
115
|
const patchFields = new AccumulatorMap();
|
|
129
116
|
collectFieldsImpl(
|
|
130
|
-
|
|
131
|
-
fragments,
|
|
132
|
-
variableValues,
|
|
133
|
-
operation,
|
|
117
|
+
exeContext,
|
|
134
118
|
runtimeTypeName,
|
|
135
119
|
fragment.selectionSet,
|
|
136
120
|
patchFields,
|
|
@@ -143,10 +127,7 @@ function collectFieldsImpl(resolvers, fragments, variableValues, operation, runt
|
|
|
143
127
|
});
|
|
144
128
|
} else {
|
|
145
129
|
collectFieldsImpl(
|
|
146
|
-
|
|
147
|
-
fragments,
|
|
148
|
-
variableValues,
|
|
149
|
-
operation,
|
|
130
|
+
exeContext,
|
|
150
131
|
runtimeTypeName,
|
|
151
132
|
fragment.selectionSet,
|
|
152
133
|
groupedFieldSet,
|
|
@@ -159,80 +140,40 @@ function collectFieldsImpl(resolvers, fragments, variableValues, operation, runt
|
|
|
159
140
|
}
|
|
160
141
|
}
|
|
161
142
|
}
|
|
162
|
-
function shouldIncludeNode(
|
|
143
|
+
function shouldIncludeNode(exeContext, node) {
|
|
163
144
|
var _a;
|
|
164
145
|
if (!((_a = node.directives) == null ? void 0 : _a.length)) {
|
|
165
146
|
return true;
|
|
166
147
|
}
|
|
167
|
-
const skip = getDirectiveValues(
|
|
168
|
-
GraphQLSkipDirective,
|
|
169
|
-
node,
|
|
170
|
-
resolvers,
|
|
171
|
-
variableValues
|
|
172
|
-
);
|
|
148
|
+
const skip = getDirectiveValues(exeContext, GraphQLSkipDirective, node);
|
|
173
149
|
if ((skip == null ? void 0 : skip.if) === true) {
|
|
174
150
|
return false;
|
|
175
151
|
}
|
|
176
|
-
const include = getDirectiveValues(
|
|
177
|
-
GraphQLIncludeDirective,
|
|
178
|
-
node,
|
|
179
|
-
resolvers,
|
|
180
|
-
variableValues
|
|
181
|
-
);
|
|
152
|
+
const include = getDirectiveValues(exeContext, GraphQLIncludeDirective, node);
|
|
182
153
|
if ((include == null ? void 0 : include.if) === false) {
|
|
183
154
|
return false;
|
|
184
155
|
}
|
|
185
156
|
return true;
|
|
186
157
|
}
|
|
187
|
-
function doesFragmentConditionMatch(fragment, typeName,
|
|
158
|
+
function doesFragmentConditionMatch(fragment, typeName, schemaFragment) {
|
|
188
159
|
const typeConditionNode = fragment.typeCondition;
|
|
189
160
|
if (!typeConditionNode) {
|
|
190
161
|
return true;
|
|
191
162
|
}
|
|
192
|
-
const
|
|
193
|
-
if (
|
|
163
|
+
const conditionalTypeName = typeConditionNode.name.value;
|
|
164
|
+
if (conditionalTypeName === typeName) {
|
|
194
165
|
return true;
|
|
195
166
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
function getSubTypes(resolvers, abstractTypes, conditionalType) {
|
|
200
|
-
const resolver = resolvers[conditionalType];
|
|
201
|
-
if (isInterfaceResolverType(resolver)) {
|
|
202
|
-
const result = resolver.__implementedBy.reduce(
|
|
203
|
-
(acc, item) => {
|
|
204
|
-
if (!abstractTypes.has(item)) {
|
|
205
|
-
const newTypes = /* @__PURE__ */ new Set([...abstractTypes, item]);
|
|
206
|
-
acc.push(...abstractTypes, ...getSubTypes(resolvers, newTypes, item));
|
|
207
|
-
}
|
|
208
|
-
return acc;
|
|
209
|
-
},
|
|
210
|
-
[]
|
|
211
|
-
);
|
|
212
|
-
return /* @__PURE__ */ new Set([...result]);
|
|
213
|
-
}
|
|
214
|
-
if (isUnionResolverType(resolver)) {
|
|
215
|
-
const result = resolver.__types.reduce((acc, item) => {
|
|
216
|
-
if (!abstractTypes.has(item)) {
|
|
217
|
-
const newTypes = /* @__PURE__ */ new Set([...abstractTypes, item]);
|
|
218
|
-
acc.push(...abstractTypes, ...getSubTypes(resolvers, newTypes, item));
|
|
219
|
-
}
|
|
220
|
-
return acc;
|
|
221
|
-
}, []);
|
|
222
|
-
return /* @__PURE__ */ new Set([...result]);
|
|
167
|
+
if (schemaFragment.isAbstractType(conditionalTypeName)) {
|
|
168
|
+
return schemaFragment.isSubType(conditionalTypeName, typeName);
|
|
223
169
|
}
|
|
224
|
-
return
|
|
170
|
+
return false;
|
|
225
171
|
}
|
|
226
172
|
function getFieldEntryKey(node) {
|
|
227
173
|
return node.alias ? node.alias.value : node.name.value;
|
|
228
174
|
}
|
|
229
|
-
function getDeferValues(
|
|
230
|
-
const defer = getDirectiveValues(
|
|
231
|
-
GraphQLDeferDirective,
|
|
232
|
-
node,
|
|
233
|
-
resolvers,
|
|
234
|
-
variableValues
|
|
235
|
-
);
|
|
175
|
+
function getDeferValues(exeContext, node) {
|
|
176
|
+
const defer = getDirectiveValues(exeContext, GraphQLDeferDirective, node);
|
|
236
177
|
if (!defer) {
|
|
237
178
|
return;
|
|
238
179
|
}
|
|
@@ -240,7 +181,7 @@ function getDeferValues(resolvers, operation, variableValues, node) {
|
|
|
240
181
|
return;
|
|
241
182
|
}
|
|
242
183
|
invariant(
|
|
243
|
-
operation.operation !== "subscription",
|
|
184
|
+
exeContext.operation.operation !== "subscription",
|
|
244
185
|
"`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`."
|
|
245
186
|
);
|
|
246
187
|
return {
|