@graphitation/supermassive 3.2.6 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/.eslintcache +1 -1
  2. package/CHANGELOG.md +18 -2
  3. package/lib/IncrementalPublisher.d.ts +131 -0
  4. package/lib/IncrementalPublisher.d.ts.map +1 -0
  5. package/lib/IncrementalPublisher.js +519 -0
  6. package/lib/IncrementalPublisher.js.map +7 -0
  7. package/lib/IncrementalPublisher.mjs +503 -0
  8. package/lib/IncrementalPublisher.mjs.map +7 -0
  9. package/lib/benchmarks/swapi-schema/resolvers.d.ts.map +1 -1
  10. package/lib/benchmarks/swapi-schema/resolvers.js +25 -0
  11. package/lib/benchmarks/swapi-schema/resolvers.js.map +2 -2
  12. package/lib/benchmarks/swapi-schema/resolvers.mjs +25 -0
  13. package/lib/benchmarks/swapi-schema/resolvers.mjs.map +2 -2
  14. package/lib/buildFieldPlan.d.ts +18 -0
  15. package/lib/buildFieldPlan.d.ts.map +1 -0
  16. package/lib/buildFieldPlan.js +120 -0
  17. package/lib/buildFieldPlan.js.map +7 -0
  18. package/lib/buildFieldPlan.mjs +101 -0
  19. package/lib/buildFieldPlan.mjs.map +7 -0
  20. package/lib/collectFields.d.ts +21 -8
  21. package/lib/collectFields.d.ts.map +1 -1
  22. package/lib/collectFields.js +97 -95
  23. package/lib/collectFields.js.map +2 -2
  24. package/lib/collectFields.mjs +97 -95
  25. package/lib/collectFields.mjs.map +2 -2
  26. package/lib/executeWithoutSchema.d.ts +7 -51
  27. package/lib/executeWithoutSchema.d.ts.map +1 -1
  28. package/lib/executeWithoutSchema.js +603 -485
  29. package/lib/executeWithoutSchema.js.map +3 -3
  30. package/lib/executeWithoutSchema.mjs +614 -486
  31. package/lib/executeWithoutSchema.mjs.map +3 -3
  32. package/lib/index.d.ts +1 -1
  33. package/lib/index.d.ts.map +1 -1
  34. package/lib/index.js.map +1 -1
  35. package/lib/index.mjs.map +1 -1
  36. package/lib/jsutils/getBySet.d.ts +2 -0
  37. package/lib/jsutils/getBySet.d.ts.map +1 -0
  38. package/lib/jsutils/getBySet.js +32 -0
  39. package/lib/jsutils/getBySet.js.map +7 -0
  40. package/lib/jsutils/getBySet.mjs +13 -0
  41. package/lib/jsutils/getBySet.mjs.map +7 -0
  42. package/lib/jsutils/isSameSet.d.ts +2 -0
  43. package/lib/jsutils/isSameSet.d.ts.map +1 -0
  44. package/lib/jsutils/isSameSet.js +34 -0
  45. package/lib/jsutils/isSameSet.js.map +7 -0
  46. package/lib/jsutils/isSameSet.mjs +15 -0
  47. package/lib/jsutils/isSameSet.mjs.map +7 -0
  48. package/lib/jsutils/promiseWithResolvers.d.ts +11 -0
  49. package/lib/jsutils/promiseWithResolvers.d.ts.map +1 -0
  50. package/lib/jsutils/promiseWithResolvers.js +32 -0
  51. package/lib/jsutils/promiseWithResolvers.js.map +7 -0
  52. package/lib/jsutils/promiseWithResolvers.mjs +13 -0
  53. package/lib/jsutils/promiseWithResolvers.mjs.map +7 -0
  54. package/lib/types.d.ts +63 -27
  55. package/lib/types.d.ts.map +1 -1
  56. package/lib/types.js.map +1 -1
  57. package/lib/values.d.ts +5 -4
  58. package/lib/values.d.ts.map +1 -1
  59. package/lib/values.js +13 -8
  60. package/lib/values.js.map +2 -2
  61. package/lib/values.mjs +13 -8
  62. package/lib/values.mjs.map +2 -2
  63. package/package.json +1 -1
@@ -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;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;IAC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D,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,eAAe,EAAE,eAAe,CAAC;CAClC;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,gBAAgB,EAC5B,eAAe,EAAE,MAAM,GACtB,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC,CAgB1C;AAWD;;;;;;;;;GASG;AAEH,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,MAAM,CAAC,sBAAsB,CAAC,EACzC,cAAc,EAAE;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAC/C,SAAS,EAAE,uBAAuB,EAClC,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,aAAa,CAAC,YAAY,CAAC,GACxC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC,CAwB1C"}
@@ -39,145 +39,141 @@ var import_AccumulatorMap = require("./jsutils/AccumulatorMap");
39
39
  var import_invariant = __toESM(require("invariant"));
40
40
  var import_definition = require("./schema/definition");
41
41
  function collectFields(exeContext, runtimeTypeName) {
42
- const { operation } = exeContext;
43
42
  const groupedFieldSet = new import_AccumulatorMap.AccumulatorMap();
44
- const patches = [];
45
- collectFieldsImpl(
46
- exeContext,
43
+ const context = {
44
+ schemaFragment: exeContext.schemaFragment,
45
+ fragments: exeContext.fragments,
46
+ variableValues: exeContext.variableValues,
47
47
  runtimeTypeName,
48
- operation.selectionSet,
49
- groupedFieldSet,
50
- patches,
51
- /* @__PURE__ */ new Set()
48
+ operation: exeContext.operation,
49
+ visitedFragmentNames: /* @__PURE__ */ new Set()
50
+ };
51
+ collectFieldsImpl(
52
+ context,
53
+ exeContext.operation.selectionSet,
54
+ groupedFieldSet
52
55
  );
53
- return { groupedFieldSet, patches };
56
+ return groupedFieldSet;
54
57
  }
55
- function collectSubfields(exeContext, returnTypeName, fieldGroup) {
56
- const subGroupedFieldSet = new import_AccumulatorMap.AccumulatorMap();
57
- const visitedFragmentNames = /* @__PURE__ */ new Set();
58
- const subPatches = [];
59
- const subFieldsAndPatches = {
60
- groupedFieldSet: subGroupedFieldSet,
61
- patches: subPatches
58
+ function collectSubfields(schemaFragment, fragments, variableValues, operation, returnTypeName, fieldDetails) {
59
+ const context = {
60
+ schemaFragment,
61
+ fragments,
62
+ variableValues,
63
+ runtimeTypeName: returnTypeName,
64
+ operation,
65
+ visitedFragmentNames: /* @__PURE__ */ new Set()
62
66
  };
63
- for (const node of fieldGroup) {
67
+ const subGroupedFieldSet = new import_AccumulatorMap.AccumulatorMap();
68
+ for (const fieldDetail of fieldDetails) {
69
+ const node = fieldDetail.node;
64
70
  if (node.selectionSet) {
65
71
  collectFieldsImpl(
66
- exeContext,
67
- returnTypeName,
72
+ context,
68
73
  node.selectionSet,
69
74
  subGroupedFieldSet,
70
- subPatches,
71
- visitedFragmentNames
75
+ fieldDetail.deferUsage
72
76
  );
73
77
  }
74
78
  }
75
- return subFieldsAndPatches;
79
+ return subGroupedFieldSet;
76
80
  }
77
- function collectFieldsImpl(exeContext, runtimeTypeName, selectionSet, groupedFieldSet, patches, visitedFragmentNames) {
81
+ function collectFieldsImpl(context, selectionSet, groupedFieldSet, parentDeferUsage, deferUsage) {
82
+ const {
83
+ schemaFragment,
84
+ fragments,
85
+ variableValues,
86
+ runtimeTypeName,
87
+ operation,
88
+ visitedFragmentNames
89
+ } = context;
78
90
  for (const selection of selectionSet.selections) {
79
91
  switch (selection.kind) {
80
92
  case import_graphql.Kind.FIELD: {
81
- if (!shouldIncludeNode(exeContext, selection)) {
93
+ if (!shouldIncludeNode(schemaFragment, variableValues, selection)) {
82
94
  continue;
83
95
  }
84
- groupedFieldSet.add(getFieldEntryKey(selection), selection);
96
+ groupedFieldSet.add(getFieldEntryKey(selection), {
97
+ node: selection,
98
+ deferUsage: deferUsage != null ? deferUsage : parentDeferUsage
99
+ });
85
100
  break;
86
101
  }
87
102
  case import_graphql.Kind.INLINE_FRAGMENT: {
88
- if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(
103
+ if (!shouldIncludeNode(schemaFragment, variableValues, selection) || !doesFragmentConditionMatch(
89
104
  selection,
90
105
  runtimeTypeName,
91
- exeContext.schemaFragment
106
+ schemaFragment
92
107
  )) {
93
108
  continue;
94
109
  }
95
- const defer = getDeferValues(exeContext, selection);
96
- if (defer) {
97
- const patchFields = new import_AccumulatorMap.AccumulatorMap();
98
- collectFieldsImpl(
99
- exeContext,
100
- runtimeTypeName,
101
- selection.selectionSet,
102
- patchFields,
103
- patches,
104
- visitedFragmentNames
105
- );
106
- patches.push({
107
- label: defer.label,
108
- groupedFieldSet: patchFields
109
- });
110
- } else {
111
- collectFieldsImpl(
112
- exeContext,
113
- runtimeTypeName,
114
- selection.selectionSet,
115
- groupedFieldSet,
116
- patches,
117
- visitedFragmentNames
118
- );
119
- }
110
+ const newDeferUsage = getDeferUsage(
111
+ schemaFragment,
112
+ operation,
113
+ variableValues,
114
+ selection,
115
+ parentDeferUsage
116
+ );
117
+ collectFieldsImpl(
118
+ context,
119
+ selection.selectionSet,
120
+ groupedFieldSet,
121
+ parentDeferUsage,
122
+ newDeferUsage != null ? newDeferUsage : deferUsage
123
+ );
120
124
  break;
121
125
  }
122
126
  case import_graphql.Kind.FRAGMENT_SPREAD: {
123
127
  const fragName = selection.name.value;
124
- if (!shouldIncludeNode(exeContext, selection)) {
125
- continue;
126
- }
127
- const defer = getDeferValues(exeContext, selection);
128
- if (visitedFragmentNames.has(fragName) && !defer) {
128
+ const newDeferUsage = getDeferUsage(
129
+ schemaFragment,
130
+ operation,
131
+ variableValues,
132
+ selection,
133
+ parentDeferUsage
134
+ );
135
+ if (!newDeferUsage && (visitedFragmentNames.has(fragName) || !shouldIncludeNode(schemaFragment, variableValues, selection))) {
129
136
  continue;
130
137
  }
131
- const fragment = exeContext.fragments[fragName];
132
- if (fragment == null || !doesFragmentConditionMatch(
133
- fragment,
134
- runtimeTypeName,
135
- exeContext.schemaFragment
136
- )) {
138
+ const fragment = fragments[fragName];
139
+ if (fragment == null || !doesFragmentConditionMatch(fragment, runtimeTypeName, schemaFragment)) {
137
140
  continue;
138
141
  }
139
- if (!defer) {
142
+ if (!newDeferUsage) {
140
143
  visitedFragmentNames.add(fragName);
141
144
  }
142
- if (defer) {
143
- const patchFields = new import_AccumulatorMap.AccumulatorMap();
144
- collectFieldsImpl(
145
- exeContext,
146
- runtimeTypeName,
147
- fragment.selectionSet,
148
- patchFields,
149
- patches,
150
- visitedFragmentNames
151
- );
152
- patches.push({
153
- label: defer.label,
154
- groupedFieldSet: patchFields
155
- });
156
- } else {
157
- collectFieldsImpl(
158
- exeContext,
159
- runtimeTypeName,
160
- fragment.selectionSet,
161
- groupedFieldSet,
162
- patches,
163
- visitedFragmentNames
164
- );
165
- }
145
+ collectFieldsImpl(
146
+ context,
147
+ fragment.selectionSet,
148
+ groupedFieldSet,
149
+ parentDeferUsage,
150
+ newDeferUsage != null ? newDeferUsage : deferUsage
151
+ );
166
152
  break;
167
153
  }
168
154
  }
169
155
  }
170
156
  }
171
- function shouldIncludeNode(exeContext, node) {
157
+ function shouldIncludeNode(schemaFragment, variableValues, node) {
172
158
  var _a;
173
159
  if (!((_a = node.directives) == null ? void 0 : _a.length)) {
174
160
  return true;
175
161
  }
176
- const skip = (0, import_values.getDirectiveValues)(exeContext, import_directives.GraphQLSkipDirective, node);
162
+ const skip = (0, import_values.getDirectiveValues)(
163
+ schemaFragment,
164
+ import_directives.GraphQLSkipDirective,
165
+ node,
166
+ variableValues
167
+ );
177
168
  if ((skip == null ? void 0 : skip.if) === true) {
178
169
  return false;
179
170
  }
180
- const include = (0, import_values.getDirectiveValues)(exeContext, import_directives.GraphQLIncludeDirective, node);
171
+ const include = (0, import_values.getDirectiveValues)(
172
+ schemaFragment,
173
+ import_directives.GraphQLIncludeDirective,
174
+ node,
175
+ variableValues
176
+ );
181
177
  if ((include == null ? void 0 : include.if) === false) {
182
178
  return false;
183
179
  }
@@ -200,8 +196,13 @@ function doesFragmentConditionMatch(fragment, typeName, { definitions }) {
200
196
  function getFieldEntryKey(node) {
201
197
  return node.alias ? node.alias.value : node.name.value;
202
198
  }
203
- function getDeferValues(exeContext, node) {
204
- const defer = (0, import_values.getDirectiveValues)(exeContext, import_directives.GraphQLDeferDirective, node);
199
+ function getDeferUsage(schemaFragment, operation, variableValues, node, parentDeferUsage) {
200
+ const defer = (0, import_values.getDirectiveValues)(
201
+ schemaFragment,
202
+ import_directives.GraphQLDeferDirective,
203
+ node,
204
+ variableValues
205
+ );
205
206
  if (!defer) {
206
207
  return;
207
208
  }
@@ -209,10 +210,11 @@ function getDeferValues(exeContext, node) {
209
210
  return;
210
211
  }
211
212
  (0, import_invariant.default)(
212
- exeContext.operation.operation !== "subscription",
213
+ operation.operation !== "subscription",
213
214
  "`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`."
214
215
  );
215
216
  return {
216
- label: typeof defer.label === "string" ? defer.label : void 0
217
+ label: typeof defer.label === "string" ? defer.label : void 0,
218
+ parentDeferUsage
217
219
  };
218
220
  }
@@ -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 { 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
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAQO;AACP,oBAAmC;AACnC,wBAIO;AAEP,4BAA+B;AAC/B,uBAAsB;AAEtB,wBAA0C;AA0BnC,SAAS,cACd,YAC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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;",
4
+ "sourcesContent": ["import {\n Kind,\n FieldNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n SelectionNode,\n SelectionSetNode,\n OperationDefinitionNode,\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\";\nimport { ObjMap } from \"./jsutils/ObjMap\";\nimport { Maybe } from \"./jsutils/Maybe\";\nimport { FieldGroup } from \"./buildFieldPlan\";\n\nexport interface DeferUsage {\n label: string | undefined;\n parentDeferUsage: DeferUsage | undefined;\n}\n\nexport interface StreamUsage {\n label: string | undefined;\n initialCount: number;\n fieldGroup: FieldGroup;\n}\n\nexport interface FieldDetails {\n node: FieldNode;\n deferUsage: DeferUsage | undefined;\n}\n\nexport type GroupedFieldSet = Map<string, FieldGroup>;\n\nexport interface PatchFields {\n label: string | undefined;\n groupedFieldSet: GroupedFieldSet;\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): Map<string, ReadonlyArray<FieldDetails>> {\n const groupedFieldSet = new AccumulatorMap<string, FieldDetails>();\n const context: CollectFieldsContext = {\n schemaFragment: exeContext.schemaFragment,\n fragments: exeContext.fragments,\n variableValues: exeContext.variableValues,\n runtimeTypeName,\n operation: exeContext.operation,\n visitedFragmentNames: new Set(),\n };\n collectFieldsImpl(\n context,\n exeContext.operation.selectionSet,\n groupedFieldSet,\n );\n return groupedFieldSet;\n}\n\ninterface CollectFieldsContext {\n schemaFragment: SchemaFragment;\n fragments: ObjMap<FragmentDefinitionNode>;\n variableValues: { [variable: string]: unknown };\n operation: OperationDefinitionNode;\n runtimeTypeName: string;\n visitedFragmentNames: Set<string>;\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 schemaFragment: SchemaFragment,\n fragments: ObjMap<FragmentDefinitionNode>,\n variableValues: { [variable: string]: unknown },\n operation: OperationDefinitionNode,\n returnTypeName: string,\n fieldDetails: ReadonlyArray<FieldDetails>,\n): Map<string, ReadonlyArray<FieldDetails>> {\n const context: CollectFieldsContext = {\n schemaFragment,\n fragments,\n variableValues,\n runtimeTypeName: returnTypeName,\n operation,\n visitedFragmentNames: new Set(),\n };\n const subGroupedFieldSet = new AccumulatorMap<string, FieldDetails>();\n\n for (const fieldDetail of fieldDetails) {\n const node = fieldDetail.node;\n if (node.selectionSet) {\n collectFieldsImpl(\n context,\n node.selectionSet,\n subGroupedFieldSet,\n fieldDetail.deferUsage,\n );\n }\n }\n\n return subGroupedFieldSet;\n}\n\n// eslint-disable-next-line max-params\nfunction collectFieldsImpl(\n context: CollectFieldsContext,\n selectionSet: SelectionSetNode,\n groupedFieldSet: AccumulatorMap<string, FieldDetails>,\n parentDeferUsage?: DeferUsage,\n deferUsage?: DeferUsage,\n): void {\n const {\n schemaFragment,\n fragments,\n variableValues,\n runtimeTypeName,\n operation,\n visitedFragmentNames,\n } = context;\n\n for (const selection of selectionSet.selections) {\n switch (selection.kind) {\n case Kind.FIELD: {\n if (!shouldIncludeNode(schemaFragment, variableValues, selection)) {\n continue;\n }\n groupedFieldSet.add(getFieldEntryKey(selection), {\n node: selection,\n deferUsage: deferUsage ?? parentDeferUsage,\n });\n break;\n }\n case Kind.INLINE_FRAGMENT: {\n if (\n !shouldIncludeNode(schemaFragment, variableValues, selection) ||\n !doesFragmentConditionMatch(\n selection,\n runtimeTypeName,\n schemaFragment,\n )\n ) {\n continue;\n }\n\n const newDeferUsage = getDeferUsage(\n schemaFragment,\n operation,\n variableValues,\n selection,\n parentDeferUsage,\n );\n\n collectFieldsImpl(\n context,\n selection.selectionSet,\n groupedFieldSet,\n parentDeferUsage,\n newDeferUsage ?? deferUsage,\n );\n\n break;\n }\n case Kind.FRAGMENT_SPREAD: {\n const fragName = selection.name.value;\n\n const newDeferUsage = getDeferUsage(\n schemaFragment,\n operation,\n variableValues,\n selection,\n parentDeferUsage,\n );\n\n if (\n !newDeferUsage &&\n (visitedFragmentNames.has(fragName) ||\n !shouldIncludeNode(schemaFragment, variableValues, selection))\n ) {\n continue;\n }\n\n const fragment = fragments[fragName];\n if (\n fragment == null ||\n !doesFragmentConditionMatch(fragment, runtimeTypeName, schemaFragment)\n ) {\n continue;\n }\n if (!newDeferUsage) {\n visitedFragmentNames.add(fragName);\n }\n\n collectFieldsImpl(\n context,\n fragment.selectionSet,\n groupedFieldSet,\n parentDeferUsage,\n newDeferUsage ?? deferUsage,\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 schemaFragment: SchemaFragment,\n variableValues: Maybe<ObjMap<unknown>>,\n node: SelectionNode,\n): boolean {\n if (!node.directives?.length) {\n return true;\n }\n\n const skip = getDirectiveValues(\n schemaFragment,\n GraphQLSkipDirective,\n node,\n variableValues,\n );\n if (skip?.if === true) {\n return false;\n }\n\n const include = getDirectiveValues(\n schemaFragment,\n GraphQLIncludeDirective,\n node,\n variableValues,\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 { 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 getDeferUsage(\n schemaFragment: SchemaFragment,\n operation: OperationDefinitionNode,\n variableValues: { [variable: string]: unknown },\n node: FragmentSpreadNode | InlineFragmentNode,\n parentDeferUsage: DeferUsage | undefined,\n): DeferUsage | undefined {\n const defer = getDirectiveValues(\n schemaFragment,\n GraphQLDeferDirective,\n node,\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 parentDeferUsage,\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBASO;AACP,oBAAmC;AACnC,wBAIO;AAEP,4BAA+B;AAC/B,uBAAsB;AAEtB,wBAA0C;AAsCnC,SAAS,cACd,YACA,iBAC0C;AAC1C,QAAM,kBAAkB,IAAI,qCAAqC;AACjE,QAAM,UAAgC;AAAA,IACpC,gBAAgB,WAAW;AAAA,IAC3B,WAAW,WAAW;AAAA,IACtB,gBAAgB,WAAW;AAAA,IAC3B;AAAA,IACA,WAAW,WAAW;AAAA,IACtB,sBAAsB,oBAAI,IAAI;AAAA,EAChC;AACA;AAAA,IACE;AAAA,IACA,WAAW,UAAU;AAAA,IACrB;AAAA,EACF;AACA,SAAO;AACT;AAsBO,SAAS,iBACd,gBACA,WACA,gBACA,WACA,gBACA,cAC0C;AAC1C,QAAM,UAAgC;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA,sBAAsB,oBAAI,IAAI;AAAA,EAChC;AACA,QAAM,qBAAqB,IAAI,qCAAqC;AAEpE,aAAW,eAAe,cAAc;AACtC,UAAM,OAAO,YAAY;AACzB,QAAI,KAAK,cAAc;AACrB;AAAA,QACE;AAAA,QACA,KAAK;AAAA,QACL;AAAA,QACA,YAAY;AAAA,MACd;AAAA,IACF;AAAA,EAC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AAA,IACvD;AAAA,EACF;AACF;",
6
6
  "names": ["invariant"]
7
7
  }
@@ -12,145 +12,141 @@ import { AccumulatorMap } from "./jsutils/AccumulatorMap.mjs";
12
12
  import invariant from "invariant";
13
13
  import { isAbstractType, isSubType } from "./schema/definition.mjs";
14
14
  function collectFields(exeContext, runtimeTypeName) {
15
- const { operation } = exeContext;
16
15
  const groupedFieldSet = new AccumulatorMap();
17
- const patches = [];
18
- collectFieldsImpl(
19
- exeContext,
16
+ const context = {
17
+ schemaFragment: exeContext.schemaFragment,
18
+ fragments: exeContext.fragments,
19
+ variableValues: exeContext.variableValues,
20
20
  runtimeTypeName,
21
- operation.selectionSet,
22
- groupedFieldSet,
23
- patches,
24
- /* @__PURE__ */ new Set()
21
+ operation: exeContext.operation,
22
+ visitedFragmentNames: /* @__PURE__ */ new Set()
23
+ };
24
+ collectFieldsImpl(
25
+ context,
26
+ exeContext.operation.selectionSet,
27
+ groupedFieldSet
25
28
  );
26
- return { groupedFieldSet, patches };
29
+ return groupedFieldSet;
27
30
  }
28
- function collectSubfields(exeContext, returnTypeName, fieldGroup) {
29
- const subGroupedFieldSet = new AccumulatorMap();
30
- const visitedFragmentNames = /* @__PURE__ */ new Set();
31
- const subPatches = [];
32
- const subFieldsAndPatches = {
33
- groupedFieldSet: subGroupedFieldSet,
34
- patches: subPatches
31
+ function collectSubfields(schemaFragment, fragments, variableValues, operation, returnTypeName, fieldDetails) {
32
+ const context = {
33
+ schemaFragment,
34
+ fragments,
35
+ variableValues,
36
+ runtimeTypeName: returnTypeName,
37
+ operation,
38
+ visitedFragmentNames: /* @__PURE__ */ new Set()
35
39
  };
36
- for (const node of fieldGroup) {
40
+ const subGroupedFieldSet = new AccumulatorMap();
41
+ for (const fieldDetail of fieldDetails) {
42
+ const node = fieldDetail.node;
37
43
  if (node.selectionSet) {
38
44
  collectFieldsImpl(
39
- exeContext,
40
- returnTypeName,
45
+ context,
41
46
  node.selectionSet,
42
47
  subGroupedFieldSet,
43
- subPatches,
44
- visitedFragmentNames
48
+ fieldDetail.deferUsage
45
49
  );
46
50
  }
47
51
  }
48
- return subFieldsAndPatches;
52
+ return subGroupedFieldSet;
49
53
  }
50
- function collectFieldsImpl(exeContext, runtimeTypeName, selectionSet, groupedFieldSet, patches, visitedFragmentNames) {
54
+ function collectFieldsImpl(context, selectionSet, groupedFieldSet, parentDeferUsage, deferUsage) {
55
+ const {
56
+ schemaFragment,
57
+ fragments,
58
+ variableValues,
59
+ runtimeTypeName,
60
+ operation,
61
+ visitedFragmentNames
62
+ } = context;
51
63
  for (const selection of selectionSet.selections) {
52
64
  switch (selection.kind) {
53
65
  case Kind.FIELD: {
54
- if (!shouldIncludeNode(exeContext, selection)) {
66
+ if (!shouldIncludeNode(schemaFragment, variableValues, selection)) {
55
67
  continue;
56
68
  }
57
- groupedFieldSet.add(getFieldEntryKey(selection), selection);
69
+ groupedFieldSet.add(getFieldEntryKey(selection), {
70
+ node: selection,
71
+ deferUsage: deferUsage != null ? deferUsage : parentDeferUsage
72
+ });
58
73
  break;
59
74
  }
60
75
  case Kind.INLINE_FRAGMENT: {
61
- if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(
76
+ if (!shouldIncludeNode(schemaFragment, variableValues, selection) || !doesFragmentConditionMatch(
62
77
  selection,
63
78
  runtimeTypeName,
64
- exeContext.schemaFragment
79
+ schemaFragment
65
80
  )) {
66
81
  continue;
67
82
  }
68
- const defer = getDeferValues(exeContext, selection);
69
- if (defer) {
70
- const patchFields = new AccumulatorMap();
71
- collectFieldsImpl(
72
- exeContext,
73
- runtimeTypeName,
74
- selection.selectionSet,
75
- patchFields,
76
- patches,
77
- visitedFragmentNames
78
- );
79
- patches.push({
80
- label: defer.label,
81
- groupedFieldSet: patchFields
82
- });
83
- } else {
84
- collectFieldsImpl(
85
- exeContext,
86
- runtimeTypeName,
87
- selection.selectionSet,
88
- groupedFieldSet,
89
- patches,
90
- visitedFragmentNames
91
- );
92
- }
83
+ const newDeferUsage = getDeferUsage(
84
+ schemaFragment,
85
+ operation,
86
+ variableValues,
87
+ selection,
88
+ parentDeferUsage
89
+ );
90
+ collectFieldsImpl(
91
+ context,
92
+ selection.selectionSet,
93
+ groupedFieldSet,
94
+ parentDeferUsage,
95
+ newDeferUsage != null ? newDeferUsage : deferUsage
96
+ );
93
97
  break;
94
98
  }
95
99
  case Kind.FRAGMENT_SPREAD: {
96
100
  const fragName = selection.name.value;
97
- if (!shouldIncludeNode(exeContext, selection)) {
98
- continue;
99
- }
100
- const defer = getDeferValues(exeContext, selection);
101
- if (visitedFragmentNames.has(fragName) && !defer) {
101
+ const newDeferUsage = getDeferUsage(
102
+ schemaFragment,
103
+ operation,
104
+ variableValues,
105
+ selection,
106
+ parentDeferUsage
107
+ );
108
+ if (!newDeferUsage && (visitedFragmentNames.has(fragName) || !shouldIncludeNode(schemaFragment, variableValues, selection))) {
102
109
  continue;
103
110
  }
104
- const fragment = exeContext.fragments[fragName];
105
- if (fragment == null || !doesFragmentConditionMatch(
106
- fragment,
107
- runtimeTypeName,
108
- exeContext.schemaFragment
109
- )) {
111
+ const fragment = fragments[fragName];
112
+ if (fragment == null || !doesFragmentConditionMatch(fragment, runtimeTypeName, schemaFragment)) {
110
113
  continue;
111
114
  }
112
- if (!defer) {
115
+ if (!newDeferUsage) {
113
116
  visitedFragmentNames.add(fragName);
114
117
  }
115
- if (defer) {
116
- const patchFields = new AccumulatorMap();
117
- collectFieldsImpl(
118
- exeContext,
119
- runtimeTypeName,
120
- fragment.selectionSet,
121
- patchFields,
122
- patches,
123
- visitedFragmentNames
124
- );
125
- patches.push({
126
- label: defer.label,
127
- groupedFieldSet: patchFields
128
- });
129
- } else {
130
- collectFieldsImpl(
131
- exeContext,
132
- runtimeTypeName,
133
- fragment.selectionSet,
134
- groupedFieldSet,
135
- patches,
136
- visitedFragmentNames
137
- );
138
- }
118
+ collectFieldsImpl(
119
+ context,
120
+ fragment.selectionSet,
121
+ groupedFieldSet,
122
+ parentDeferUsage,
123
+ newDeferUsage != null ? newDeferUsage : deferUsage
124
+ );
139
125
  break;
140
126
  }
141
127
  }
142
128
  }
143
129
  }
144
- function shouldIncludeNode(exeContext, node) {
130
+ function shouldIncludeNode(schemaFragment, variableValues, node) {
145
131
  var _a;
146
132
  if (!((_a = node.directives) == null ? void 0 : _a.length)) {
147
133
  return true;
148
134
  }
149
- const skip = getDirectiveValues(exeContext, GraphQLSkipDirective, node);
135
+ const skip = getDirectiveValues(
136
+ schemaFragment,
137
+ GraphQLSkipDirective,
138
+ node,
139
+ variableValues
140
+ );
150
141
  if ((skip == null ? void 0 : skip.if) === true) {
151
142
  return false;
152
143
  }
153
- const include = getDirectiveValues(exeContext, GraphQLIncludeDirective, node);
144
+ const include = getDirectiveValues(
145
+ schemaFragment,
146
+ GraphQLIncludeDirective,
147
+ node,
148
+ variableValues
149
+ );
154
150
  if ((include == null ? void 0 : include.if) === false) {
155
151
  return false;
156
152
  }
@@ -173,8 +169,13 @@ function doesFragmentConditionMatch(fragment, typeName, { definitions }) {
173
169
  function getFieldEntryKey(node) {
174
170
  return node.alias ? node.alias.value : node.name.value;
175
171
  }
176
- function getDeferValues(exeContext, node) {
177
- const defer = getDirectiveValues(exeContext, GraphQLDeferDirective, node);
172
+ function getDeferUsage(schemaFragment, operation, variableValues, node, parentDeferUsage) {
173
+ const defer = getDirectiveValues(
174
+ schemaFragment,
175
+ GraphQLDeferDirective,
176
+ node,
177
+ variableValues
178
+ );
178
179
  if (!defer) {
179
180
  return;
180
181
  }
@@ -182,11 +183,12 @@ function getDeferValues(exeContext, node) {
182
183
  return;
183
184
  }
184
185
  invariant(
185
- exeContext.operation.operation !== "subscription",
186
+ operation.operation !== "subscription",
186
187
  "`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`."
187
188
  );
188
189
  return {
189
- label: typeof defer.label === "string" ? defer.label : void 0
190
+ label: typeof defer.label === "string" ? defer.label : void 0,
191
+ parentDeferUsage
190
192
  };
191
193
  }
192
194
  export {