@graphitation/supermassive 3.15.3 → 3.16.1-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.eslintcache +1 -1
  2. package/CHANGELOG.md +1 -9
  3. package/lib/executeWithoutSchema.d.ts.map +1 -1
  4. package/lib/executeWithoutSchema.js +41 -0
  5. package/lib/executeWithoutSchema.js.map +2 -2
  6. package/lib/executeWithoutSchema.mjs +41 -0
  7. package/lib/executeWithoutSchema.mjs.map +2 -2
  8. package/lib/schema/definition.d.ts +54 -19
  9. package/lib/schema/definition.d.ts.map +1 -1
  10. package/lib/schema/definition.js +127 -18
  11. package/lib/schema/definition.js.map +3 -3
  12. package/lib/schema/definition.mjs +109 -16
  13. package/lib/schema/definition.mjs.map +2 -2
  14. package/lib/schema/directives.d.ts.map +1 -1
  15. package/lib/schema/directives.js +9 -4
  16. package/lib/schema/directives.js.map +2 -2
  17. package/lib/schema/directives.mjs +10 -5
  18. package/lib/schema/directives.mjs.map +2 -2
  19. package/lib/utilities/decodeASTSchema.d.ts.map +1 -1
  20. package/lib/utilities/decodeASTSchema.js +185 -33
  21. package/lib/utilities/decodeASTSchema.js.map +2 -2
  22. package/lib/utilities/decodeASTSchema.mjs +196 -36
  23. package/lib/utilities/decodeASTSchema.mjs.map +2 -2
  24. package/lib/utilities/encodeASTSchema.d.ts +5 -1
  25. package/lib/utilities/encodeASTSchema.d.ts.map +1 -1
  26. package/lib/utilities/encodeASTSchema.js +171 -38
  27. package/lib/utilities/encodeASTSchema.js.map +2 -2
  28. package/lib/utilities/encodeASTSchema.mjs +171 -38
  29. package/lib/utilities/encodeASTSchema.mjs.map +2 -2
  30. package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js +1 -1
  31. package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js.map +2 -2
  32. package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs +2 -2
  33. package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs.map +2 -2
  34. package/lib/utilities/mergeSchemaDefinitions.d.ts +6 -2
  35. package/lib/utilities/mergeSchemaDefinitions.d.ts.map +1 -1
  36. package/lib/utilities/mergeSchemaDefinitions.js +86 -5
  37. package/lib/utilities/mergeSchemaDefinitions.js.map +3 -3
  38. package/lib/utilities/mergeSchemaDefinitions.mjs +96 -7
  39. package/lib/utilities/mergeSchemaDefinitions.mjs.map +3 -3
  40. package/lib/utilities/subtractSchemaDefinitions.js +4 -4
  41. package/lib/utilities/subtractSchemaDefinitions.js.map +2 -2
  42. package/lib/utilities/subtractSchemaDefinitions.mjs +5 -5
  43. package/lib/utilities/subtractSchemaDefinitions.mjs.map +2 -2
  44. package/lib/values.js +2 -2
  45. package/lib/values.js.map +2 -2
  46. package/lib/values.mjs +4 -4
  47. package/lib/values.mjs.map +2 -2
  48. package/package.json +1 -1
@@ -1,21 +1,29 @@
1
1
  // src/utilities/mergeSchemaDefinitions.ts
2
2
  import {
3
3
  getDirectiveDefinitionArgs,
4
- getDirectiveName,
4
+ getDirectiveDefinitionName,
5
+ getEnumMetadata,
6
+ getEnumValues,
5
7
  getFieldArgs,
8
+ getFieldMetadata,
6
9
  getFields,
7
10
  getInputObjectFields,
11
+ getTypeDefinitionMetadataIndex,
12
+ getTypeDefinitionMetadata,
8
13
  isInputObjectTypeDefinition,
9
14
  isInterfaceTypeDefinition,
10
15
  isObjectTypeDefinition,
11
16
  setDirectiveDefinitionArgs,
12
- setFieldArgs
17
+ setFieldArgs,
18
+ setFieldDirectives,
19
+ getDirectiveName,
20
+ isEnumTypeDefinition
13
21
  } from "../schema/definition.mjs";
14
22
  import { inspect } from "../jsutils/inspect.mjs";
15
23
  function createSchemaDefinitions(definitions) {
16
24
  return mergeSchemaDefinitions({ types: {}, directives: [] }, definitions);
17
25
  }
18
- function mergeSchemaDefinitions(accumulator, definitions) {
26
+ function mergeSchemaDefinitions(accumulator, definitions, options) {
19
27
  var _a;
20
28
  if (!definitions.length) {
21
29
  return accumulator;
@@ -24,7 +32,7 @@ function mergeSchemaDefinitions(accumulator, definitions) {
24
32
  if (!accumulator.types) {
25
33
  accumulator.types = source.types;
26
34
  } else if (source.types) {
27
- mergeTypes(accumulator.types, source.types);
35
+ mergeTypes(accumulator.types, source.types, options);
28
36
  }
29
37
  if (!accumulator.directives) {
30
38
  accumulator.directives = source.directives;
@@ -34,10 +42,38 @@ function mergeSchemaDefinitions(accumulator, definitions) {
34
42
  }
35
43
  return accumulator;
36
44
  }
45
+ function mergeTypeMetadata(target, source) {
46
+ var _a;
47
+ const targetMetadata = getTypeDefinitionMetadata(target);
48
+ const sourceMetadata = getTypeDefinitionMetadata(source);
49
+ const metadataIndex = getTypeDefinitionMetadataIndex(target);
50
+ if (!sourceMetadata || !metadataIndex) {
51
+ return;
52
+ }
53
+ if (!targetMetadata) {
54
+ (_a = target[metadataIndex]) != null ? _a : target[metadataIndex] = {};
55
+ const targetMetadata2 = target[metadataIndex];
56
+ if (sourceMetadata == null ? void 0 : sourceMetadata.directives) {
57
+ targetMetadata2.directives = [...sourceMetadata.directives];
58
+ }
59
+ return;
60
+ }
61
+ if (sourceMetadata.directives && targetMetadata.directives) {
62
+ for (const sourceDirective of sourceMetadata.directives) {
63
+ const directiveName = getDirectiveName(sourceDirective);
64
+ const exists = targetMetadata.directives.some(
65
+ (d) => getDirectiveName(d) === directiveName
66
+ );
67
+ if (!exists) {
68
+ targetMetadata.directives.push(sourceDirective);
69
+ }
70
+ }
71
+ }
72
+ }
37
73
  function mergeDirectives(target, source) {
38
74
  for (const sourceDirective of source) {
39
75
  const targetDirective = target.find(
40
- (directive) => getDirectiveName(directive) === getDirectiveName(sourceDirective)
76
+ (directive) => getDirectiveDefinitionName(directive) === getDirectiveDefinitionName(sourceDirective)
41
77
  );
42
78
  if (!targetDirective) {
43
79
  target.push(sourceDirective);
@@ -55,13 +91,14 @@ function mergeDirectives(target, source) {
55
91
  mergeInputValues(targetArgs, sourceArgs);
56
92
  }
57
93
  }
58
- function mergeTypes(target, source) {
94
+ function mergeTypes(target, source, options) {
59
95
  for (const [typeName, sourceDef] of Object.entries(source)) {
60
96
  const targetDef = target[typeName];
61
97
  if (!targetDef) {
62
98
  target[typeName] = sourceDef;
63
99
  continue;
64
100
  }
101
+ mergeTypeMetadata(targetDef, sourceDef);
65
102
  if (isObjectTypeDefinition(targetDef) && isObjectTypeDefinition(sourceDef) || isInterfaceTypeDefinition(targetDef) && isInterfaceTypeDefinition(sourceDef)) {
66
103
  mergeFields(getFields(targetDef), getFields(sourceDef));
67
104
  mergeInterfaces(targetDef, sourceDef);
@@ -74,6 +111,10 @@ function mergeTypes(target, source) {
74
111
  );
75
112
  continue;
76
113
  }
114
+ if ((options == null ? void 0 : options.mergeEnumValues) && isEnumTypeDefinition(targetDef) && isEnumTypeDefinition(sourceDef)) {
115
+ mergeEnumValues(targetDef, sourceDef);
116
+ continue;
117
+ }
77
118
  if (targetDef[0] !== sourceDef[0]) {
78
119
  throw new Error(
79
120
  `Type ${typeName} is represented differently in different schema fragments:
@@ -84,7 +125,7 @@ function mergeTypes(target, source) {
84
125
  }
85
126
  }
86
127
  function mergeFields(target, source) {
87
- var _a;
128
+ var _a, _b;
88
129
  for (const [fieldName, sourceDef] of Object.entries(source)) {
89
130
  const targetDef = target[fieldName];
90
131
  if (!target[fieldName] || !Array.isArray(targetDef)) {
@@ -96,6 +137,27 @@ function mergeFields(target, source) {
96
137
  const targetArgs = (_a = getFieldArgs(targetDef)) != null ? _a : setFieldArgs(targetDef, {});
97
138
  mergeInputValues(targetArgs, sourceArgs);
98
139
  }
140
+ const sourceDirectives = getFieldMetadata(sourceDef);
141
+ if (sourceDirectives) {
142
+ const targetMetadata = (_b = getFieldMetadata(targetDef)) != null ? _b : setFieldDirectives(targetDef, {});
143
+ if (targetMetadata.directives && sourceDirectives.directives) {
144
+ mergeFieldDirectives(
145
+ targetMetadata.directives,
146
+ sourceDirectives.directives
147
+ );
148
+ }
149
+ }
150
+ }
151
+ }
152
+ function mergeFieldDirectives(target, source) {
153
+ for (const sourceDirective of source) {
154
+ const directiveName = getDirectiveName(sourceDirective);
155
+ const exists = target.some(
156
+ (d) => getDirectiveName(d) === directiveName
157
+ );
158
+ if (!exists) {
159
+ target.push(sourceDirective);
160
+ }
99
161
  }
100
162
  }
101
163
  function mergeInterfaces(target, source) {
@@ -114,6 +176,33 @@ function mergeInterfaces(target, source) {
114
176
  }
115
177
  }
116
178
  }
179
+ function mergeEnumValues(target, source) {
180
+ const targetValues = getEnumValues(target);
181
+ const sourceValues = getEnumValues(source);
182
+ for (const value of sourceValues) {
183
+ if (!targetValues.includes(value)) {
184
+ targetValues.push(value);
185
+ }
186
+ }
187
+ const sourceMetadata = getEnumMetadata(source);
188
+ if (!(sourceMetadata == null ? void 0 : sourceMetadata.values)) {
189
+ return;
190
+ }
191
+ const targetMetadata = getEnumMetadata(target);
192
+ if (!targetMetadata) {
193
+ target[2] = { values: { ...sourceMetadata.values } };
194
+ return;
195
+ }
196
+ if (!targetMetadata.values) {
197
+ targetMetadata.values = { ...sourceMetadata.values };
198
+ return;
199
+ }
200
+ for (const [valueName, valueMeta] of Object.entries(sourceMetadata.values)) {
201
+ if (!targetMetadata.values[valueName]) {
202
+ targetMetadata.values[valueName] = valueMeta;
203
+ }
204
+ }
205
+ }
117
206
  function mergeInputValues(target, source) {
118
207
  for (const [fieldName, sourceDef] of Object.entries(source)) {
119
208
  const targetDef = target[fieldName];
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utilities/mergeSchemaDefinitions.ts"],
4
- "sourcesContent": ["import {\n DirectiveDefinitionTuple,\n FieldDefinitionRecord,\n getDirectiveDefinitionArgs,\n getDirectiveName,\n getFieldArgs,\n getFields,\n getInputObjectFields,\n InputValueDefinitionRecord,\n InterfaceTypeDefinitionTuple,\n isInputObjectTypeDefinition,\n isInterfaceTypeDefinition,\n isObjectTypeDefinition,\n ObjectTypeDefinitionTuple,\n SchemaDefinitions,\n setDirectiveDefinitionArgs,\n setFieldArgs,\n TypeDefinitionsRecord,\n} from \"../schema/definition\";\nimport { inspect } from \"../jsutils/inspect\";\n\nexport function createSchemaDefinitions(definitions: SchemaDefinitions[]) {\n return mergeSchemaDefinitions({ types: {}, directives: [] }, definitions);\n}\n\nexport function mergeSchemaDefinitions(\n accumulator: SchemaDefinitions,\n definitions: SchemaDefinitions[],\n): SchemaDefinitions {\n if (!definitions.length) {\n return accumulator;\n }\n for (const source of definitions) {\n if (!accumulator.types) {\n accumulator.types = source.types;\n } else if (source.types) {\n mergeTypes(accumulator.types, source.types);\n }\n if (!accumulator.directives) {\n accumulator.directives = source.directives;\n } else if (source.directives?.length) {\n mergeDirectives(accumulator.directives, source.directives);\n }\n }\n return accumulator;\n}\n\nexport function mergeDirectives(\n target: DirectiveDefinitionTuple[],\n source: DirectiveDefinitionTuple[],\n) {\n for (const sourceDirective of source) {\n const targetDirective = target.find(\n (directive) =>\n getDirectiveName(directive) === getDirectiveName(sourceDirective),\n );\n if (!targetDirective) {\n target.push(sourceDirective);\n continue;\n }\n const sourceArgs = getDirectiveDefinitionArgs(sourceDirective);\n if (!sourceArgs) {\n continue;\n }\n const targetArgs = getDirectiveDefinitionArgs(targetDirective);\n if (!targetArgs) {\n setDirectiveDefinitionArgs(targetDirective, sourceArgs);\n continue;\n }\n mergeInputValues(targetArgs, sourceArgs);\n }\n}\n\n/**\n * Adds missing definitions from source into target. Mutates target in place.\n */\nexport function mergeTypes(\n target: TypeDefinitionsRecord,\n source: TypeDefinitionsRecord,\n): void {\n for (const [typeName, sourceDef] of Object.entries(source)) {\n const targetDef = target[typeName];\n if (!targetDef) {\n target[typeName] = sourceDef;\n continue;\n }\n if (\n (isObjectTypeDefinition(targetDef) &&\n isObjectTypeDefinition(sourceDef)) ||\n (isInterfaceTypeDefinition(targetDef) &&\n isInterfaceTypeDefinition(sourceDef))\n ) {\n mergeFields(getFields(targetDef), getFields(sourceDef));\n mergeInterfaces(targetDef, sourceDef);\n continue;\n }\n if (\n isInputObjectTypeDefinition(targetDef) &&\n isInputObjectTypeDefinition(sourceDef)\n ) {\n mergeInputValues(\n getInputObjectFields(targetDef),\n getInputObjectFields(sourceDef),\n );\n continue;\n }\n // Note: not merging scalars, unions and enums - assuming they are fully defined by the first occurrence\n if (targetDef[0] !== sourceDef[0]) {\n throw new Error(\n `Type ${typeName} is represented differently in different schema fragments:\\n` +\n inspect(targetDef) +\n `\\n` +\n inspect(sourceDef),\n );\n }\n }\n}\n\nfunction mergeFields(\n target: FieldDefinitionRecord,\n source: FieldDefinitionRecord,\n) {\n for (const [fieldName, sourceDef] of Object.entries(source)) {\n const targetDef = target[fieldName];\n if (!target[fieldName] || !Array.isArray(targetDef)) {\n target[fieldName] = sourceDef;\n continue;\n }\n const sourceArgs = getFieldArgs(sourceDef);\n if (sourceArgs) {\n const targetArgs = getFieldArgs(targetDef) ?? setFieldArgs(targetDef, {});\n mergeInputValues(targetArgs, sourceArgs);\n }\n }\n}\n\nfunction mergeInterfaces(\n target: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n source: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n): void {\n const targetInterfaces = target[2];\n const sourceInterfaces = source[2];\n\n if (!sourceInterfaces) {\n return;\n }\n\n if (!targetInterfaces) {\n target[2] = [...sourceInterfaces];\n return;\n }\n\n for (const interfaceName of sourceInterfaces) {\n if (!targetInterfaces.includes(interfaceName)) {\n targetInterfaces.push(interfaceName);\n }\n }\n}\n\nfunction mergeInputValues(\n target: InputValueDefinitionRecord,\n source: InputValueDefinitionRecord,\n) {\n for (const [fieldName, sourceDef] of Object.entries(source)) {\n const targetDef = target[fieldName];\n if (!target[fieldName] || !Array.isArray(targetDef)) {\n target[fieldName] = sourceDef;\n }\n // Note: not merging defaultValue - assuming it is fully defined by the first occurrence\n }\n}\n"],
5
- "mappings": ";AAAA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAG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a;AAAA,IACrC;AAAA,EACF;AACF;AAEA,SAAS,iBACP,QACA,QACA;AACA,aAAW,CAAC,WAAW,SAAS,KAAK,OAAO,QAAQ,MAAM,GAAG;AAC3D,UAAM,YAAY,OAAO,SAAS;AAClC,QAAI,CAAC,OAAO,SAAS,KAAK,CAAC,MAAM,QAAQ,SAAS,GAAG;AACnD,aAAO,SAAS,IAAI;AAAA,IACtB;AAAA,EAEF;AACF;",
6
- "names": []
4
+ "sourcesContent": ["import {\n DirectiveDefinitionTuple,\n DirectiveTuple,\n EnumTypeDefinitionTuple,\n FieldDefinitionRecord,\n getDirectiveDefinitionArgs,\n getDirectiveDefinitionName,\n getEnumMetadata,\n getEnumValues,\n getFieldArgs,\n getFieldMetadata,\n getFields,\n getInputObjectFields,\n getTypeDefinitionMetadataIndex,\n getTypeDefinitionMetadata,\n InputValueDefinitionRecord,\n InterfaceTypeDefinitionTuple,\n isInputObjectTypeDefinition,\n isInterfaceTypeDefinition,\n isObjectTypeDefinition,\n ObjectTypeDefinitionTuple,\n SchemaDefinitions,\n setDirectiveDefinitionArgs,\n setFieldArgs,\n setFieldDirectives,\n TypeDefinitionsRecord,\n TypeDefinitionTuple,\n TypeDefinitionMetadata,\n getDirectiveName,\n isEnumTypeDefinition,\n} from \"../schema/definition\";\nimport { inspect } from \"../jsutils/inspect\";\n\nexport function createSchemaDefinitions(definitions: SchemaDefinitions[]) {\n return mergeSchemaDefinitions({ types: {}, directives: [] }, definitions);\n}\n\ntype MergeSchemaDefinitionsOptions = {\n mergeEnumValues?: boolean;\n};\nexport function mergeSchemaDefinitions(\n accumulator: SchemaDefinitions,\n definitions: SchemaDefinitions[],\n options?: MergeSchemaDefinitionsOptions,\n): SchemaDefinitions {\n if (!definitions.length) {\n return accumulator;\n }\n for (const source of definitions) {\n if (!accumulator.types) {\n accumulator.types = source.types;\n } else if (source.types) {\n mergeTypes(accumulator.types, source.types, options);\n }\n if (!accumulator.directives) {\n accumulator.directives = source.directives;\n } else if (source.directives?.length) {\n mergeDirectives(accumulator.directives, source.directives);\n }\n }\n return accumulator;\n}\n\nfunction mergeTypeMetadata(\n target: TypeDefinitionTuple,\n source: TypeDefinitionTuple,\n): void {\n const targetMetadata: TypeDefinitionMetadata | undefined =\n getTypeDefinitionMetadata(target);\n const sourceMetadata: TypeDefinitionMetadata | undefined =\n getTypeDefinitionMetadata(source);\n\n const metadataIndex = getTypeDefinitionMetadataIndex(target);\n if (!sourceMetadata || !metadataIndex) {\n return;\n }\n\n if (!targetMetadata) {\n target[metadataIndex] ??= {};\n const targetMetadata: TypeDefinitionMetadata = target[\n metadataIndex\n ] as TypeDefinitionMetadata;\n if (sourceMetadata?.directives) {\n targetMetadata.directives = [...sourceMetadata.directives];\n }\n return;\n }\n\n if (sourceMetadata.directives && targetMetadata.directives) {\n for (const sourceDirective of sourceMetadata.directives) {\n const directiveName = getDirectiveName(sourceDirective);\n const exists = targetMetadata.directives.some(\n (d: DirectiveTuple) => getDirectiveName(d) === directiveName,\n );\n if (!exists) {\n targetMetadata.directives.push(sourceDirective);\n }\n }\n }\n}\n\nexport function mergeDirectives(\n target: DirectiveDefinitionTuple[],\n source: DirectiveDefinitionTuple[],\n) {\n for (const sourceDirective of source) {\n const targetDirective = target.find(\n (directive) =>\n getDirectiveDefinitionName(directive) ===\n getDirectiveDefinitionName(sourceDirective),\n );\n if (!targetDirective) {\n target.push(sourceDirective);\n continue;\n }\n const sourceArgs = getDirectiveDefinitionArgs(sourceDirective);\n if (!sourceArgs) {\n continue;\n }\n const targetArgs = getDirectiveDefinitionArgs(targetDirective);\n if (!targetArgs) {\n setDirectiveDefinitionArgs(targetDirective, sourceArgs);\n continue;\n }\n mergeInputValues(targetArgs, sourceArgs);\n }\n}\n\n/**\n * Adds missing definitions from source into target. Mutates target in place.\n */\nexport function mergeTypes(\n target: TypeDefinitionsRecord,\n source: TypeDefinitionsRecord,\n options?: MergeSchemaDefinitionsOptions,\n): void {\n for (const [typeName, sourceDef] of Object.entries(source)) {\n const targetDef = target[typeName];\n if (!targetDef) {\n target[typeName] = sourceDef;\n continue;\n }\n\n mergeTypeMetadata(targetDef, sourceDef);\n\n if (\n (isObjectTypeDefinition(targetDef) &&\n isObjectTypeDefinition(sourceDef)) ||\n (isInterfaceTypeDefinition(targetDef) &&\n isInterfaceTypeDefinition(sourceDef))\n ) {\n mergeFields(getFields(targetDef), getFields(sourceDef));\n mergeInterfaces(targetDef, sourceDef);\n continue;\n }\n if (\n isInputObjectTypeDefinition(targetDef) &&\n isInputObjectTypeDefinition(sourceDef)\n ) {\n mergeInputValues(\n getInputObjectFields(targetDef),\n getInputObjectFields(sourceDef),\n );\n continue;\n }\n\n if (\n options?.mergeEnumValues &&\n isEnumTypeDefinition(targetDef) &&\n isEnumTypeDefinition(sourceDef)\n ) {\n mergeEnumValues(targetDef, sourceDef);\n continue;\n }\n\n // Note: not merging scalars, unions and enums - assuming they are fully defined by the first occurrence\n if (targetDef[0] !== sourceDef[0]) {\n throw new Error(\n `Type ${typeName} is represented differently in different schema fragments:\\n` +\n inspect(targetDef) +\n `\\n` +\n inspect(sourceDef),\n );\n }\n }\n}\n\nfunction mergeFields(\n target: FieldDefinitionRecord,\n source: FieldDefinitionRecord,\n) {\n for (const [fieldName, sourceDef] of Object.entries(source)) {\n const targetDef = target[fieldName];\n if (!target[fieldName] || !Array.isArray(targetDef)) {\n target[fieldName] = sourceDef;\n continue;\n }\n const sourceArgs = getFieldArgs(sourceDef);\n if (sourceArgs) {\n const targetArgs = getFieldArgs(targetDef) ?? setFieldArgs(targetDef, {});\n mergeInputValues(targetArgs, sourceArgs);\n }\n\n const sourceDirectives = getFieldMetadata(sourceDef);\n if (sourceDirectives) {\n const targetMetadata =\n getFieldMetadata(targetDef) ?? setFieldDirectives(targetDef, {});\n if (targetMetadata.directives && sourceDirectives.directives) {\n mergeFieldDirectives(\n targetMetadata.directives,\n sourceDirectives.directives,\n );\n }\n }\n }\n}\n\nfunction mergeFieldDirectives(\n target: DirectiveTuple[],\n source: DirectiveTuple[],\n): void {\n for (const sourceDirective of source) {\n const directiveName = getDirectiveName(sourceDirective);\n const exists = target.some(\n (d: DirectiveTuple) => getDirectiveName(d) === directiveName,\n );\n if (!exists) {\n target.push(sourceDirective);\n }\n }\n}\n\nfunction mergeInterfaces(\n target: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n source: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n): void {\n const targetInterfaces = target[2];\n const sourceInterfaces = source[2];\n\n if (!sourceInterfaces) {\n return;\n }\n\n if (!targetInterfaces) {\n target[2] = [...sourceInterfaces];\n return;\n }\n\n for (const interfaceName of sourceInterfaces) {\n if (!targetInterfaces.includes(interfaceName)) {\n targetInterfaces.push(interfaceName);\n }\n }\n}\n\nfunction mergeEnumValues(\n target: EnumTypeDefinitionTuple,\n source: EnumTypeDefinitionTuple,\n): void {\n const targetValues = getEnumValues(target);\n const sourceValues = getEnumValues(source);\n\n for (const value of sourceValues) {\n if (!targetValues.includes(value)) {\n targetValues.push(value);\n }\n }\n\n const sourceMetadata = getEnumMetadata(source);\n if (!sourceMetadata?.values) {\n return;\n }\n\n const targetMetadata = getEnumMetadata(target);\n if (!targetMetadata) {\n target[2] = { values: { ...sourceMetadata.values } };\n return;\n }\n\n if (!targetMetadata.values) {\n targetMetadata.values = { ...sourceMetadata.values };\n return;\n }\n\n for (const [valueName, valueMeta] of Object.entries(sourceMetadata.values)) {\n if (!targetMetadata.values[valueName]) {\n targetMetadata.values[valueName] = valueMeta;\n }\n }\n}\n\nfunction mergeInputValues(\n target: InputValueDefinitionRecord,\n source: InputValueDefinitionRecord,\n) {\n for (const [fieldName, sourceDef] of Object.entries(source)) {\n const targetDef = target[fieldName];\n if (!target[fieldName] || !Array.isArray(targetDef)) {\n target[fieldName] = sourceDef;\n }\n // Note: not merging defaultValue - assuming it is fully defined by the first occurrence\n }\n}\n"],
5
+ "mappings": ";AAAA;AAAA,EAKE;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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trahendValues, strict) {
280
280
  function subtractDirectives(minuendDirectives, subtrahendDirectives, strict) {
281
281
  const result = [];
282
282
  for (const minuendDirective of minuendDirectives) {
283
- const minuendName = (0, import_definition.getDirectiveName)(minuendDirective);
283
+ const minuendName = (0, import_definition.getDirectiveDefinitionName)(minuendDirective);
284
284
  const subtrahendDirective = subtrahendDirectives.find(
285
- (d) => (0, import_definition.getDirectiveName)(d) === minuendName
285
+ (d) => (0, import_definition.getDirectiveDefinitionName)(d) === minuendName
286
286
  );
287
287
  if (!subtrahendDirective) {
288
288
  result.push(minuendDirective);
@@ -318,9 +318,9 @@ function subtractDirectives(minuendDirectives, subtrahendDirectives, strict) {
318
318
  }
319
319
  }
320
320
  for (const subtrahendDirective of subtrahendDirectives) {
321
- const subtrahendName = (0, import_definition.getDirectiveName)(subtrahendDirective);
321
+ const subtrahendName = (0, import_definition.getDirectiveDefinitionName)(subtrahendDirective);
322
322
  const exists = minuendDirectives.some(
323
- (d) => (0, import_definition.getDirectiveName)(d) === subtrahendName
323
+ (d) => (0, import_definition.getDirectiveDefinitionName)(d) === subtrahendName
324
324
  );
325
325
  if (!exists) {
326
326
  if (strict) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utilities/subtractSchemaDefinitions.ts"],
4
- "sourcesContent": ["// Note: this utility is vibe-coded. Use at your own risk! :)\nimport {\n SchemaDefinitions,\n DirectiveDefinitionTuple,\n FieldDefinitionRecord,\n InputValueDefinitionRecord,\n TypeDefinitionsRecord,\n TypeDefinitionTuple,\n getDirectiveDefinitionArgs,\n getDirectiveName,\n getEnumValues,\n getFieldTypeReference,\n getFieldArgs,\n getFields,\n getInputObjectFields,\n getInputValueTypeReference,\n getUnionTypeMembers,\n isEnumTypeDefinition,\n isInputObjectTypeDefinition,\n isInterfaceTypeDefinition,\n isObjectTypeDefinition,\n isScalarTypeDefinition,\n isUnionTypeDefinition,\n createEnumTypeDefinition,\n createInputObjectTypeDefinition,\n createInterfaceTypeDefinition,\n createObjectTypeDefinition,\n createUnionTypeDefinition,\n getObjectTypeInterfaces,\n getInterfaceTypeInterfaces,\n} from \"../schema/definition\";\nimport { inspect } from \"../jsutils/inspect\";\n\n/**\n * Subtracts schema definitions from minuend that exist in subtrahend.\n * Returns a new SchemaDefinitions object without mutating inputs.\n *\n * @param minuend - The schema definitions to subtract from\n * @param subtrahend - The schema definitions to subtract\n * @param strict - If true, throws errors on items in subtrahend that are not in minuend; if false, ignores them\n * @returns A new SchemaDefinitions with elements from minuend not in subtrahend\n */\nexport function subtractSchemaDefinitions(\n minuend: SchemaDefinitions,\n subtrahend: SchemaDefinitions,\n strict = false,\n): SchemaDefinitions {\n const result: SchemaDefinitions = {\n types: {},\n directives: [],\n };\n\n // Subtract types\n if (minuend.types && subtrahend.types) {\n result.types = subtractTypes(minuend.types, subtrahend.types, strict);\n } else if (minuend.types) {\n result.types = { ...minuend.types };\n }\n\n // Subtract directives\n if (minuend.directives && subtrahend.directives) {\n result.directives = subtractDirectives(\n minuend.directives,\n subtrahend.directives,\n strict,\n );\n } else if (minuend.directives) {\n result.directives = [...minuend.directives];\n }\n\n return result;\n}\n\n/**\n * Subtracts types from minuend that exist in subtrahend.\n */\nfunction subtractTypes(\n minuend: TypeDefinitionsRecord,\n subtrahend: TypeDefinitionsRecord,\n strict: boolean,\n): TypeDefinitionsRecord {\n const result: TypeDefinitionsRecord = {};\n\n for (const [typeName, minuendDef] of Object.entries(minuend)) {\n const subtrahendDef = subtrahend[typeName];\n\n if (!subtrahendDef) {\n // Type doesn't exist in subtrahend, keep it\n result[typeName] = minuendDef;\n continue;\n }\n\n // Validate type kinds match\n if (minuendDef[0] !== subtrahendDef[0]) {\n throw new Error(\n `Type ${typeName} is represented differently in different schema fragments:\\n` +\n inspect(minuendDef) +\n `\\n` +\n inspect(subtrahendDef),\n );\n }\n\n // Handle different type kinds\n const subtractedType = subtractType(\n typeName,\n minuendDef,\n subtrahendDef,\n strict,\n );\n if (subtractedType) {\n result[typeName] = subtractedType;\n }\n }\n\n // Check for types in subtrahend that don't exist in minuend\n for (const typeName of Object.keys(subtrahend)) {\n if (!(typeName in minuend)) {\n if (strict) {\n throw new Error(`Type ${typeName} does not exist in minuend`);\n }\n // In non-strict mode, ignore missing types\n }\n }\n\n return result;\n}\n\n/**\n * Subtracts a single type definition.\n */\nfunction subtractType(\n typeName: string,\n minuendDef: TypeDefinitionTuple,\n subtrahendDef: TypeDefinitionTuple,\n strict: boolean,\n): TypeDefinitionTuple | null {\n if (\n isObjectTypeDefinition(minuendDef) &&\n isObjectTypeDefinition(subtrahendDef)\n ) {\n const subtractedFields = subtractFields(\n typeName,\n getFields(minuendDef),\n getFields(subtrahendDef),\n strict,\n );\n if (Object.keys(subtractedFields).length === 0) {\n return null; // All fields removed\n }\n const interfaces = getObjectTypeInterfaces(minuendDef);\n return createObjectTypeDefinition(\n subtractedFields,\n interfaces.length > 0 ? interfaces : undefined,\n );\n }\n\n if (\n isInterfaceTypeDefinition(minuendDef) &&\n isInterfaceTypeDefinition(subtrahendDef)\n ) {\n const subtractedFields = subtractFields(\n typeName,\n getFields(minuendDef),\n getFields(subtrahendDef),\n strict,\n );\n if (Object.keys(subtractedFields).length === 0) {\n return null; // All fields removed\n }\n const interfaces = getInterfaceTypeInterfaces(minuendDef);\n return createInterfaceTypeDefinition(\n subtractedFields,\n interfaces.length > 0 ? interfaces : undefined,\n );\n }\n\n if (\n isInputObjectTypeDefinition(minuendDef) &&\n isInputObjectTypeDefinition(subtrahendDef)\n ) {\n const subtractedFields = subtractInputFields(\n typeName,\n getInputObjectFields(minuendDef),\n getInputObjectFields(subtrahendDef),\n strict,\n );\n if (Object.keys(subtractedFields).length === 0) {\n return null; // All fields removed\n }\n return createInputObjectTypeDefinition(subtractedFields);\n }\n\n if (\n isUnionTypeDefinition(minuendDef) &&\n isUnionTypeDefinition(subtrahendDef)\n ) {\n const subtractedMembers = subtractUnionMembers(\n typeName,\n getUnionTypeMembers(minuendDef),\n getUnionTypeMembers(subtrahendDef),\n strict,\n );\n if (subtractedMembers.length === 0) {\n return null; // All members removed\n }\n return createUnionTypeDefinition(subtractedMembers);\n }\n\n if (isEnumTypeDefinition(minuendDef) && isEnumTypeDefinition(subtrahendDef)) {\n const subtractedValues = subtractEnumValues(\n typeName,\n getEnumValues(minuendDef),\n getEnumValues(subtrahendDef),\n strict,\n );\n if (subtractedValues.length === 0) {\n return null; // All values removed\n }\n return createEnumTypeDefinition(subtractedValues);\n }\n\n if (\n isScalarTypeDefinition(minuendDef) &&\n isScalarTypeDefinition(subtrahendDef)\n ) {\n // Scalars are atomic - if subtrahend has it, remove entire scalar\n return null;\n }\n\n return null;\n}\n\n/**\n * Subtracts fields from object/interface types.\n */\nfunction subtractFields(\n typeName: string,\n minuendFields: FieldDefinitionRecord,\n subtrahendFields: FieldDefinitionRecord,\n strict: boolean,\n): FieldDefinitionRecord {\n const result: FieldDefinitionRecord = {};\n\n for (const [fieldName, minuendField] of Object.entries(minuendFields)) {\n const subtrahendField = subtrahendFields[fieldName];\n\n if (!subtrahendField) {\n // Field doesn't exist in subtrahend, keep it\n result[fieldName] = minuendField;\n continue;\n }\n\n // Validate field types match\n const minuendType = getFieldTypeReference(minuendField);\n const subtrahendType = getFieldTypeReference(subtrahendField);\n if (minuendType !== subtrahendType) {\n throw new Error(\n `Field ${typeName}.${fieldName} has different type: ${inspect(\n minuendType,\n )} vs ${inspect(subtrahendType)}`,\n );\n }\n\n // Validate field arguments match exactly\n const minuendArgs = getFieldArgs(minuendField);\n const subtrahendArgs = getFieldArgs(subtrahendField);\n\n // Both must have same argument structure\n if (!minuendArgs && !subtrahendArgs) {\n // Both have no arguments, field can be subtracted\n } else if (!minuendArgs || !subtrahendArgs) {\n // One has args, other doesn't - not exact match\n throw new Error(\n `Field arguments must match exactly for subtraction. Field ${typeName}.${fieldName} has different argument structures.`,\n );\n } else {\n // Both have arguments, compare them\n const minuendArgKeys = Object.keys(minuendArgs).sort();\n const subtrahendArgKeys = Object.keys(subtrahendArgs).sort();\n\n if (\n minuendArgKeys.length !== subtrahendArgKeys.length ||\n !minuendArgKeys.every((key, index) => key === subtrahendArgKeys[index])\n ) {\n throw new Error(\n `Field arguments must match exactly for subtraction. Field ${typeName}.${fieldName} has different argument keys.`,\n );\n }\n\n // Check each argument type matches\n for (const argName of minuendArgKeys) {\n const minuendArgType = getInputValueTypeReference(minuendArgs[argName]);\n const subtrahendArgType = getInputValueTypeReference(\n subtrahendArgs[argName],\n );\n if (minuendArgType !== subtrahendArgType) {\n throw new Error(\n `Field arguments must match exactly for subtraction. Field ${typeName}.${fieldName} argument ${argName} has different types.`,\n );\n }\n }\n }\n\n // Field exists in subtrahend and matches exactly, remove it\n }\n\n // Check for fields in subtrahend that don't exist in minuend\n for (const fieldName of Object.keys(subtrahendFields)) {\n if (!(fieldName in minuendFields)) {\n if (strict) {\n throw new Error(\n `Field ${typeName}.${fieldName} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing fields\n }\n }\n\n return result;\n}\n\n/**\n * Subtracts input fields from input object types.\n */\nfunction subtractInputFields(\n typeName: string,\n minuendFields: InputValueDefinitionRecord,\n subtrahendFields: InputValueDefinitionRecord,\n strict: boolean,\n): InputValueDefinitionRecord {\n const result: InputValueDefinitionRecord = {};\n\n for (const [fieldName, minuendField] of Object.entries(minuendFields)) {\n const subtrahendField = subtrahendFields[fieldName];\n\n if (!subtrahendField) {\n // Field doesn't exist in subtrahend, keep it\n result[fieldName] = minuendField;\n continue;\n }\n\n // Validate field types match\n const minuendType = getInputValueTypeReference(minuendField);\n const subtrahendType = getInputValueTypeReference(subtrahendField);\n if (minuendType !== subtrahendType) {\n throw new Error(\n `Input field ${typeName}.${fieldName} has different type: ${inspect(\n minuendType,\n )} vs ${inspect(subtrahendType)}`,\n );\n }\n\n // Field exists in subtrahend, remove it\n }\n\n // Check for fields in subtrahend that don't exist in minuend\n for (const fieldName of Object.keys(subtrahendFields)) {\n if (!(fieldName in minuendFields)) {\n if (strict) {\n throw new Error(\n `Input field ${typeName}.${fieldName} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing fields\n }\n }\n\n return result;\n}\n\n/**\n * Subtracts union members.\n */\nfunction subtractUnionMembers(\n typeName: string,\n minuendMembers: string[],\n subtrahendMembers: string[],\n strict: boolean,\n): string[] {\n // Union types must match exactly for subtraction\n const minuendSet = new Set(minuendMembers);\n const subtrahendSet = new Set(subtrahendMembers);\n\n // Check if they have the same members\n if (\n minuendMembers.length === subtrahendMembers.length &&\n minuendMembers.every((member) => subtrahendSet.has(member))\n ) {\n // Exact match - remove the entire union\n return [];\n }\n\n // Check for members in subtrahend that don't exist in minuend\n for (const member of subtrahendMembers) {\n if (!minuendSet.has(member)) {\n if (strict) {\n throw new Error(\n `Union ${typeName}: member ${member} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing members and keep the original union\n return minuendMembers;\n }\n }\n\n // If we get here, all subtrahend members exist in minuend but they don't match exactly\n throw new Error(\n `Union types must match exactly for subtraction. Union ${typeName} has different member sets.`,\n );\n}\n\n/**\n * Subtracts enum values.\n */\nfunction subtractEnumValues(\n typeName: string,\n minuendValues: string[],\n subtrahendValues: string[],\n strict: boolean,\n): string[] {\n // Enum types must match exactly for subtraction\n const minuendSet = new Set(minuendValues);\n const subtrahendSet = new Set(subtrahendValues);\n\n // Check if they have the same values\n if (\n minuendValues.length === subtrahendValues.length &&\n minuendValues.every((value) => subtrahendSet.has(value))\n ) {\n // Exact match - remove the entire enum\n return [];\n }\n\n // Check for values in subtrahend that don't exist in minuend\n for (const value of subtrahendValues) {\n if (!minuendSet.has(value)) {\n if (strict) {\n throw new Error(\n `Enum ${typeName}: value ${value} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing values and keep the original enum\n return minuendValues;\n }\n }\n\n // If we get here, all subtrahend values exist in minuend but they don't match exactly\n throw new Error(\n `Enum types must match exactly for subtraction. Enum ${typeName} has different value sets.`,\n );\n}\n\n/**\n * Subtracts directives.\n */\nfunction subtractDirectives(\n minuendDirectives: DirectiveDefinitionTuple[],\n subtrahendDirectives: DirectiveDefinitionTuple[],\n strict: boolean,\n): DirectiveDefinitionTuple[] {\n const result: DirectiveDefinitionTuple[] = [];\n\n for (const minuendDirective of minuendDirectives) {\n const minuendName = getDirectiveName(minuendDirective);\n const subtrahendDirective = subtrahendDirectives.find(\n (d) => getDirectiveName(d) === minuendName,\n );\n\n if (!subtrahendDirective) {\n // Directive doesn't exist in subtrahend, keep it\n result.push(minuendDirective);\n continue;\n }\n\n // Directive exists, check arguments\n const minuendArgs = getDirectiveDefinitionArgs(minuendDirective);\n const subtrahendArgs = getDirectiveDefinitionArgs(subtrahendDirective);\n\n if (!minuendArgs && !subtrahendArgs) {\n // Both have no arguments, remove entire directive\n continue;\n }\n\n if (!minuendArgs || !subtrahendArgs) {\n // One has args, other doesn't - arguments don't match exactly\n throw new Error(\n `Directive arguments must match exactly for subtraction. Directive ${minuendName} has different argument structures.`,\n );\n }\n\n // Both have arguments, check if they match exactly\n const minuendArgKeys = Object.keys(minuendArgs).sort();\n const subtrahendArgKeys = Object.keys(subtrahendArgs).sort();\n\n if (\n minuendArgKeys.length !== subtrahendArgKeys.length ||\n !minuendArgKeys.every((key, index) => key === subtrahendArgKeys[index])\n ) {\n throw new Error(\n `Directive arguments must match exactly for subtraction. Directive ${minuendName} has different argument keys.`,\n );\n }\n\n // Check each argument type matches\n for (const argName of minuendArgKeys) {\n const minuendArgType = getInputValueTypeReference(minuendArgs[argName]);\n const subtrahendArgType = getInputValueTypeReference(\n subtrahendArgs[argName],\n );\n if (minuendArgType !== subtrahendArgType) {\n throw new Error(\n `Directive arguments must match exactly for subtraction. Directive ${minuendName} argument ${argName} has different types.`,\n );\n }\n }\n\n // Arguments match exactly, remove entire directive\n }\n\n // Check for directives in subtrahend that don't exist in minuend\n for (const subtrahendDirective of subtrahendDirectives) {\n const subtrahendName = getDirectiveName(subtrahendDirective);\n const exists = minuendDirectives.some(\n (d) => getDirectiveName(d) === subtrahendName,\n );\n if (!exists) {\n if (strict) {\n throw new Error(\n `Directive ${subtrahendName} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing directives\n }\n }\n\n return result;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBA6BO;AACP,qBAAwB;AAWjB,SAAS,0BACd,SACA,YACA,SAAS,OACU;AACnB,QAAM,SAA4B;AAAA,IAChC,OAAO,CAAC;AAAA,IACR,YAAY,CAAC;AAAA,EACf;AAGA,MAAI,QAAQ,SAAS,WAAW,OAAO;AACrC,WAAO,QAAQ,cAAc,QAAQ,OAAO,WAAW,OAAO,MAAM;AAAA,EACtE,WAAW,QAAQ,OAAO;AACxB,WAAO,QAAQ,EAAE,GAAG,QAAQ,MAAM;AAAA,EACpC;AAGA,MAAI,QAAQ,cAAc,WAAW,YAAY;AAC/C,WAAO,aAAa;AAAA,MAClB,QAAQ;AAAA,MACR,WAAW;AAAA,MACX;AAAA,IACF;AAAA,EACF,WAAW,QAAQ,YAAY;AAC7B,WAAO,aAAa,CAAC,GAAG,QAAQ,UAAU;AAAA,EAC5C;AAEA,SAAO;AACT;AAKA,SAAS,cACP,SACA,YACA,QACuB;AACvB,QAAM,SAAgC,CAAC;AAEvC,aAAW,CAAC,UAAU,UAAU,KAAK,OAAO,QAAQ,OAAO,GAAG;AAC5D,UAAM,gBAAgB,WAAW,QAAQ;AAEzC,QAAI,CAAC,eAAe;AAElB,aAAO,QAAQ,IAAI;AACnB;AAAA,IACF;AAGA,QAAI,WAAW,CAAC,MAAM,cAAc,CAAC,GAAG;AACtC,YAAM,IAAI;AAAA,QACR,QAAQ;AAAA,QACN,wBAAQ,UAAU,IAClB;AAAA,QACA,wBAAQ,aAAa;AAAA,MACzB;AAAA,IACF;AAGA,UAAM,iBAAiB;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,QAAI,gBAAgB;AAClB,aAAO,QAAQ,IAAI;A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SAAO;AACT;",
4
+ "sourcesContent": ["// Note: this utility is vibe-coded. Use at your own risk! :)\nimport {\n SchemaDefinitions,\n DirectiveDefinitionTuple,\n FieldDefinitionRecord,\n InputValueDefinitionRecord,\n TypeDefinitionsRecord,\n TypeDefinitionTuple,\n getDirectiveDefinitionArgs,\n getDirectiveDefinitionName,\n getEnumValues,\n getFieldTypeReference,\n getFieldArgs,\n getFields,\n getInputObjectFields,\n getInputValueTypeReference,\n getUnionTypeMembers,\n isEnumTypeDefinition,\n isInputObjectTypeDefinition,\n isInterfaceTypeDefinition,\n isObjectTypeDefinition,\n isScalarTypeDefinition,\n isUnionTypeDefinition,\n createEnumTypeDefinition,\n createInputObjectTypeDefinition,\n createInterfaceTypeDefinition,\n createObjectTypeDefinition,\n createUnionTypeDefinition,\n getObjectTypeInterfaces,\n getInterfaceTypeInterfaces,\n} from \"../schema/definition\";\nimport { inspect } from \"../jsutils/inspect\";\n\n/**\n * Subtracts schema definitions from minuend that exist in subtrahend.\n * Returns a new SchemaDefinitions object without mutating inputs.\n *\n * @param minuend - The schema definitions to subtract from\n * @param subtrahend - The schema definitions to subtract\n * @param strict - If true, throws errors on items in subtrahend that are not in minuend; if false, ignores them\n * @returns A new SchemaDefinitions with elements from minuend not in subtrahend\n */\nexport function subtractSchemaDefinitions(\n minuend: SchemaDefinitions,\n subtrahend: SchemaDefinitions,\n strict = false,\n): SchemaDefinitions {\n const result: SchemaDefinitions = {\n types: {},\n directives: [],\n };\n\n // Subtract types\n if (minuend.types && subtrahend.types) {\n result.types = subtractTypes(minuend.types, subtrahend.types, strict);\n } else if (minuend.types) {\n result.types = { ...minuend.types };\n }\n\n // Subtract directives\n if (minuend.directives && subtrahend.directives) {\n result.directives = subtractDirectives(\n minuend.directives,\n subtrahend.directives,\n strict,\n );\n } else if (minuend.directives) {\n result.directives = [...minuend.directives];\n }\n\n return result;\n}\n\n/**\n * Subtracts types from minuend that exist in subtrahend.\n */\nfunction subtractTypes(\n minuend: TypeDefinitionsRecord,\n subtrahend: TypeDefinitionsRecord,\n strict: boolean,\n): TypeDefinitionsRecord {\n const result: TypeDefinitionsRecord = {};\n\n for (const [typeName, minuendDef] of Object.entries(minuend)) {\n const subtrahendDef = subtrahend[typeName];\n\n if (!subtrahendDef) {\n // Type doesn't exist in subtrahend, keep it\n result[typeName] = minuendDef;\n continue;\n }\n\n // Validate type kinds match\n if (minuendDef[0] !== subtrahendDef[0]) {\n throw new Error(\n `Type ${typeName} is represented differently in different schema fragments:\\n` +\n inspect(minuendDef) +\n `\\n` +\n inspect(subtrahendDef),\n );\n }\n\n // Handle different type kinds\n const subtractedType = subtractType(\n typeName,\n minuendDef,\n subtrahendDef,\n strict,\n );\n if (subtractedType) {\n result[typeName] = subtractedType;\n }\n }\n\n // Check for types in subtrahend that don't exist in minuend\n for (const typeName of Object.keys(subtrahend)) {\n if (!(typeName in minuend)) {\n if (strict) {\n throw new Error(`Type ${typeName} does not exist in minuend`);\n }\n // In non-strict mode, ignore missing types\n }\n }\n\n return result;\n}\n\n/**\n * Subtracts a single type definition.\n */\nfunction subtractType(\n typeName: string,\n minuendDef: TypeDefinitionTuple,\n subtrahendDef: TypeDefinitionTuple,\n strict: boolean,\n): TypeDefinitionTuple | null {\n if (\n isObjectTypeDefinition(minuendDef) &&\n isObjectTypeDefinition(subtrahendDef)\n ) {\n const subtractedFields = subtractFields(\n typeName,\n getFields(minuendDef),\n getFields(subtrahendDef),\n strict,\n );\n if (Object.keys(subtractedFields).length === 0) {\n return null; // All fields removed\n }\n const interfaces = getObjectTypeInterfaces(minuendDef);\n return createObjectTypeDefinition(\n subtractedFields,\n interfaces.length > 0 ? interfaces : undefined,\n );\n }\n\n if (\n isInterfaceTypeDefinition(minuendDef) &&\n isInterfaceTypeDefinition(subtrahendDef)\n ) {\n const subtractedFields = subtractFields(\n typeName,\n getFields(minuendDef),\n getFields(subtrahendDef),\n strict,\n );\n if (Object.keys(subtractedFields).length === 0) {\n return null; // All fields removed\n }\n const interfaces = getInterfaceTypeInterfaces(minuendDef);\n return createInterfaceTypeDefinition(\n subtractedFields,\n interfaces.length > 0 ? interfaces : undefined,\n );\n }\n\n if (\n isInputObjectTypeDefinition(minuendDef) &&\n isInputObjectTypeDefinition(subtrahendDef)\n ) {\n const subtractedFields = subtractInputFields(\n typeName,\n getInputObjectFields(minuendDef),\n getInputObjectFields(subtrahendDef),\n strict,\n );\n if (Object.keys(subtractedFields).length === 0) {\n return null; // All fields removed\n }\n return createInputObjectTypeDefinition(subtractedFields);\n }\n\n if (\n isUnionTypeDefinition(minuendDef) &&\n isUnionTypeDefinition(subtrahendDef)\n ) {\n const subtractedMembers = subtractUnionMembers(\n typeName,\n getUnionTypeMembers(minuendDef),\n getUnionTypeMembers(subtrahendDef),\n strict,\n );\n if (subtractedMembers.length === 0) {\n return null; // All members removed\n }\n return createUnionTypeDefinition(subtractedMembers);\n }\n\n if (isEnumTypeDefinition(minuendDef) && isEnumTypeDefinition(subtrahendDef)) {\n const subtractedValues = subtractEnumValues(\n typeName,\n getEnumValues(minuendDef),\n getEnumValues(subtrahendDef),\n strict,\n );\n if (subtractedValues.length === 0) {\n return null; // All values removed\n }\n return createEnumTypeDefinition(subtractedValues);\n }\n\n if (\n isScalarTypeDefinition(minuendDef) &&\n isScalarTypeDefinition(subtrahendDef)\n ) {\n // Scalars are atomic - if subtrahend has it, remove entire scalar\n return null;\n }\n\n return null;\n}\n\n/**\n * Subtracts fields from object/interface types.\n */\nfunction subtractFields(\n typeName: string,\n minuendFields: FieldDefinitionRecord,\n subtrahendFields: FieldDefinitionRecord,\n strict: boolean,\n): FieldDefinitionRecord {\n const result: FieldDefinitionRecord = {};\n\n for (const [fieldName, minuendField] of Object.entries(minuendFields)) {\n const subtrahendField = subtrahendFields[fieldName];\n\n if (!subtrahendField) {\n // Field doesn't exist in subtrahend, keep it\n result[fieldName] = minuendField;\n continue;\n }\n\n // Validate field types match\n const minuendType = getFieldTypeReference(minuendField);\n const subtrahendType = getFieldTypeReference(subtrahendField);\n if (minuendType !== subtrahendType) {\n throw new Error(\n `Field ${typeName}.${fieldName} has different type: ${inspect(\n minuendType,\n )} vs ${inspect(subtrahendType)}`,\n );\n }\n\n // Validate field arguments match exactly\n const minuendArgs = getFieldArgs(minuendField);\n const subtrahendArgs = getFieldArgs(subtrahendField);\n\n // Both must have same argument structure\n if (!minuendArgs && !subtrahendArgs) {\n // Both have no arguments, field can be subtracted\n } else if (!minuendArgs || !subtrahendArgs) {\n // One has args, other doesn't - not exact match\n throw new Error(\n `Field arguments must match exactly for subtraction. Field ${typeName}.${fieldName} has different argument structures.`,\n );\n } else {\n // Both have arguments, compare them\n const minuendArgKeys = Object.keys(minuendArgs).sort();\n const subtrahendArgKeys = Object.keys(subtrahendArgs).sort();\n\n if (\n minuendArgKeys.length !== subtrahendArgKeys.length ||\n !minuendArgKeys.every((key, index) => key === subtrahendArgKeys[index])\n ) {\n throw new Error(\n `Field arguments must match exactly for subtraction. Field ${typeName}.${fieldName} has different argument keys.`,\n );\n }\n\n // Check each argument type matches\n for (const argName of minuendArgKeys) {\n const minuendArgType = getInputValueTypeReference(minuendArgs[argName]);\n const subtrahendArgType = getInputValueTypeReference(\n subtrahendArgs[argName],\n );\n if (minuendArgType !== subtrahendArgType) {\n throw new Error(\n `Field arguments must match exactly for subtraction. Field ${typeName}.${fieldName} argument ${argName} has different types.`,\n );\n }\n }\n }\n\n // Field exists in subtrahend and matches exactly, remove it\n }\n\n // Check for fields in subtrahend that don't exist in minuend\n for (const fieldName of Object.keys(subtrahendFields)) {\n if (!(fieldName in minuendFields)) {\n if (strict) {\n throw new Error(\n `Field ${typeName}.${fieldName} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing fields\n }\n }\n\n return result;\n}\n\n/**\n * Subtracts input fields from input object types.\n */\nfunction subtractInputFields(\n typeName: string,\n minuendFields: InputValueDefinitionRecord,\n subtrahendFields: InputValueDefinitionRecord,\n strict: boolean,\n): InputValueDefinitionRecord {\n const result: InputValueDefinitionRecord = {};\n\n for (const [fieldName, minuendField] of Object.entries(minuendFields)) {\n const subtrahendField = subtrahendFields[fieldName];\n\n if (!subtrahendField) {\n // Field doesn't exist in subtrahend, keep it\n result[fieldName] = minuendField;\n continue;\n }\n\n // Validate field types match\n const minuendType = getInputValueTypeReference(minuendField);\n const subtrahendType = getInputValueTypeReference(subtrahendField);\n if (minuendType !== subtrahendType) {\n throw new Error(\n `Input field ${typeName}.${fieldName} has different type: ${inspect(\n minuendType,\n )} vs ${inspect(subtrahendType)}`,\n );\n }\n\n // Field exists in subtrahend, remove it\n }\n\n // Check for fields in subtrahend that don't exist in minuend\n for (const fieldName of Object.keys(subtrahendFields)) {\n if (!(fieldName in minuendFields)) {\n if (strict) {\n throw new Error(\n `Input field ${typeName}.${fieldName} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing fields\n }\n }\n\n return result;\n}\n\n/**\n * Subtracts union members.\n */\nfunction subtractUnionMembers(\n typeName: string,\n minuendMembers: string[],\n subtrahendMembers: string[],\n strict: boolean,\n): string[] {\n // Union types must match exactly for subtraction\n const minuendSet = new Set(minuendMembers);\n const subtrahendSet = new Set(subtrahendMembers);\n\n // Check if they have the same members\n if (\n minuendMembers.length === subtrahendMembers.length &&\n minuendMembers.every((member) => subtrahendSet.has(member))\n ) {\n // Exact match - remove the entire union\n return [];\n }\n\n // Check for members in subtrahend that don't exist in minuend\n for (const member of subtrahendMembers) {\n if (!minuendSet.has(member)) {\n if (strict) {\n throw new Error(\n `Union ${typeName}: member ${member} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing members and keep the original union\n return minuendMembers;\n }\n }\n\n // If we get here, all subtrahend members exist in minuend but they don't match exactly\n throw new Error(\n `Union types must match exactly for subtraction. Union ${typeName} has different member sets.`,\n );\n}\n\n/**\n * Subtracts enum values.\n */\nfunction subtractEnumValues(\n typeName: string,\n minuendValues: string[],\n subtrahendValues: string[],\n strict: boolean,\n): string[] {\n // Enum types must match exactly for subtraction\n const minuendSet = new Set(minuendValues);\n const subtrahendSet = new Set(subtrahendValues);\n\n // Check if they have the same values\n if (\n minuendValues.length === subtrahendValues.length &&\n minuendValues.every((value) => subtrahendSet.has(value))\n ) {\n // Exact match - remove the entire enum\n return [];\n }\n\n // Check for values in subtrahend that don't exist in minuend\n for (const value of subtrahendValues) {\n if (!minuendSet.has(value)) {\n if (strict) {\n throw new Error(\n `Enum ${typeName}: value ${value} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing values and keep the original enum\n return minuendValues;\n }\n }\n\n // If we get here, all subtrahend values exist in minuend but they don't match exactly\n throw new Error(\n `Enum types must match exactly for subtraction. Enum ${typeName} has different value sets.`,\n );\n}\n\n/**\n * Subtracts directives.\n */\nfunction subtractDirectives(\n minuendDirectives: DirectiveDefinitionTuple[],\n subtrahendDirectives: DirectiveDefinitionTuple[],\n strict: boolean,\n): DirectiveDefinitionTuple[] {\n const result: DirectiveDefinitionTuple[] = [];\n\n for (const minuendDirective of minuendDirectives) {\n const minuendName = getDirectiveDefinitionName(minuendDirective);\n const subtrahendDirective = subtrahendDirectives.find(\n (d) => getDirectiveDefinitionName(d) === minuendName,\n );\n\n if (!subtrahendDirective) {\n // Directive doesn't exist in subtrahend, keep it\n result.push(minuendDirective);\n continue;\n }\n\n // Directive exists, check arguments\n const minuendArgs = getDirectiveDefinitionArgs(minuendDirective);\n const subtrahendArgs = getDirectiveDefinitionArgs(subtrahendDirective);\n\n if (!minuendArgs && !subtrahendArgs) {\n // Both have no arguments, remove entire directive\n continue;\n }\n\n if (!minuendArgs || !subtrahendArgs) {\n // One has args, other doesn't - arguments don't match exactly\n throw new Error(\n `Directive arguments must match exactly for subtraction. Directive ${minuendName} has different argument structures.`,\n );\n }\n\n // Both have arguments, check if they match exactly\n const minuendArgKeys = Object.keys(minuendArgs).sort();\n const subtrahendArgKeys = Object.keys(subtrahendArgs).sort();\n\n if (\n minuendArgKeys.length !== subtrahendArgKeys.length ||\n !minuendArgKeys.every((key, index) => key === subtrahendArgKeys[index])\n ) {\n throw new Error(\n `Directive arguments must match exactly for subtraction. Directive ${minuendName} has different argument keys.`,\n );\n }\n\n // Check each argument type matches\n for (const argName of minuendArgKeys) {\n const minuendArgType = getInputValueTypeReference(minuendArgs[argName]);\n const subtrahendArgType = getInputValueTypeReference(\n subtrahendArgs[argName],\n );\n if (minuendArgType !== subtrahendArgType) {\n throw new Error(\n `Directive arguments must match exactly for subtraction. Directive ${minuendName} argument ${argName} has different types.`,\n );\n }\n }\n\n // Arguments match exactly, remove entire directive\n }\n\n // Check for directives in subtrahend that don't exist in minuend\n for (const subtrahendDirective of subtrahendDirectives) {\n const subtrahendName = getDirectiveDefinitionName(subtrahendDirective);\n const exists = minuendDirectives.some(\n (d) => getDirectiveDefinitionName(d) === subtrahendName,\n );\n if (!exists) {\n if (strict) {\n throw new Error(\n `Directive ${subtrahendName} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing directives\n }\n }\n\n return result;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBA6BO;AACP,qBAAwB;AAWjB,SAAS,0BACd,SACA,YACA,SAAS,OACU;AACnB,QAAM,SAA4B;AAAA,IAChC,OAAO,CAAC;AAAA,IACR,YAAY,CAAC;AAAA,EACf;AAGA,MAAI,QAAQ,SAAS,WAAW,OAAO;AACrC,WAAO,QAAQ,cAAc,QAAQ,OAAO,WAAW,OAAO,MAAM;AAAA,EACtE,WAAW,QAAQ,OAAO;AACxB,WAAO,QAAQ,EAAE,GAAG,QAAQ,MAAM;AAAA,EACpC;AAGA,MAAI,QAAQ,cAAc,WAAW,YAAY;AAC/C,WAAO,aAAa;AAAA,MAClB,QAAQ;AAAA,MACR,WAAW;AAAA,MACX;AAAA,IACF;AAAA,EACF,WAAW,QAAQ,YAAY;AAC7B,WAAO,aAAa,CAAC,GAAG,QAAQ,UAAU;AAAA,EAC5C;AAEA,SAAO;AACT;AAKA,SAAS,cACP,SACA,YACA,QACuB;AACvB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YAAY,OAAO,CAAC;AACtE,YAAM,wBAAoB;AAAA,QACxB,eAAe,OAAO;AAAA,MACxB;AACA,UAAI,mBAAmB,mBAAmB;AACxC,cAAM,IAAI;AAAA,UACR,qEAAqE,wBAAwB;AAAA,QAC/F;AAAA,MACF;AAAA,IACF;AAAA,EAGF;AAGA,aAAW,uBAAuB,sBAAsB;AACtD,UAAM,qBAAiB,8CAA2B,mBAAmB;AACrE,UAAM,SAAS,kBAAkB;AAAA,MAC/B,CAAC,UAAM,8CAA2B,CAAC,MAAM;AAAA,IAC3C;AACA,QAAI,CAAC,QAAQ;AACX,UAAI,QAAQ;AACV,cAAM,IAAI;AAAA,UACR,aAAa;AAAA,QACf;AAAA,MACF;AAAA,IAEF;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  // src/utilities/subtractSchemaDefinitions.ts
2
2
  import {
3
3
  getDirectiveDefinitionArgs,
4
- getDirectiveName,
4
+ getDirectiveDefinitionName,
5
5
  getEnumValues,
6
6
  getFieldTypeReference,
7
7
  getFieldArgs,
@@ -281,9 +281,9 @@ function subtractEnumValues(typeName, minuendValues, subtrahendValues, strict) {
281
281
  function subtractDirectives(minuendDirectives, subtrahendDirectives, strict) {
282
282
  const result = [];
283
283
  for (const minuendDirective of minuendDirectives) {
284
- const minuendName = getDirectiveName(minuendDirective);
284
+ const minuendName = getDirectiveDefinitionName(minuendDirective);
285
285
  const subtrahendDirective = subtrahendDirectives.find(
286
- (d) => getDirectiveName(d) === minuendName
286
+ (d) => getDirectiveDefinitionName(d) === minuendName
287
287
  );
288
288
  if (!subtrahendDirective) {
289
289
  result.push(minuendDirective);
@@ -319,9 +319,9 @@ function subtractDirectives(minuendDirectives, subtrahendDirectives, strict) {
319
319
  }
320
320
  }
321
321
  for (const subtrahendDirective of subtrahendDirectives) {
322
- const subtrahendName = getDirectiveName(subtrahendDirective);
322
+ const subtrahendName = getDirectiveDefinitionName(subtrahendDirective);
323
323
  const exists = minuendDirectives.some(
324
- (d) => getDirectiveName(d) === subtrahendName
324
+ (d) => getDirectiveDefinitionName(d) === subtrahendName
325
325
  );
326
326
  if (!exists) {
327
327
  if (strict) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utilities/subtractSchemaDefinitions.ts"],
4
- "sourcesContent": ["// Note: this utility is vibe-coded. Use at your own risk! :)\nimport {\n SchemaDefinitions,\n DirectiveDefinitionTuple,\n FieldDefinitionRecord,\n InputValueDefinitionRecord,\n TypeDefinitionsRecord,\n TypeDefinitionTuple,\n getDirectiveDefinitionArgs,\n getDirectiveName,\n getEnumValues,\n getFieldTypeReference,\n getFieldArgs,\n getFields,\n getInputObjectFields,\n getInputValueTypeReference,\n getUnionTypeMembers,\n isEnumTypeDefinition,\n isInputObjectTypeDefinition,\n isInterfaceTypeDefinition,\n isObjectTypeDefinition,\n isScalarTypeDefinition,\n isUnionTypeDefinition,\n createEnumTypeDefinition,\n createInputObjectTypeDefinition,\n createInterfaceTypeDefinition,\n createObjectTypeDefinition,\n createUnionTypeDefinition,\n getObjectTypeInterfaces,\n getInterfaceTypeInterfaces,\n} from \"../schema/definition\";\nimport { inspect } from \"../jsutils/inspect\";\n\n/**\n * Subtracts schema definitions from minuend that exist in subtrahend.\n * Returns a new SchemaDefinitions object without mutating inputs.\n *\n * @param minuend - The schema definitions to subtract from\n * @param subtrahend - The schema definitions to subtract\n * @param strict - If true, throws errors on items in subtrahend that are not in minuend; if false, ignores them\n * @returns A new SchemaDefinitions with elements from minuend not in subtrahend\n */\nexport function subtractSchemaDefinitions(\n minuend: SchemaDefinitions,\n subtrahend: SchemaDefinitions,\n strict = false,\n): SchemaDefinitions {\n const result: SchemaDefinitions = {\n types: {},\n directives: [],\n };\n\n // Subtract types\n if (minuend.types && subtrahend.types) {\n result.types = subtractTypes(minuend.types, subtrahend.types, strict);\n } else if (minuend.types) {\n result.types = { ...minuend.types };\n }\n\n // Subtract directives\n if (minuend.directives && subtrahend.directives) {\n result.directives = subtractDirectives(\n minuend.directives,\n subtrahend.directives,\n strict,\n );\n } else if (minuend.directives) {\n result.directives = [...minuend.directives];\n }\n\n return result;\n}\n\n/**\n * Subtracts types from minuend that exist in subtrahend.\n */\nfunction subtractTypes(\n minuend: TypeDefinitionsRecord,\n subtrahend: TypeDefinitionsRecord,\n strict: boolean,\n): TypeDefinitionsRecord {\n const result: TypeDefinitionsRecord = {};\n\n for (const [typeName, minuendDef] of Object.entries(minuend)) {\n const subtrahendDef = subtrahend[typeName];\n\n if (!subtrahendDef) {\n // Type doesn't exist in subtrahend, keep it\n result[typeName] = minuendDef;\n continue;\n }\n\n // Validate type kinds match\n if (minuendDef[0] !== subtrahendDef[0]) {\n throw new Error(\n `Type ${typeName} is represented differently in different schema fragments:\\n` +\n inspect(minuendDef) +\n `\\n` +\n inspect(subtrahendDef),\n );\n }\n\n // Handle different type kinds\n const subtractedType = subtractType(\n typeName,\n minuendDef,\n subtrahendDef,\n strict,\n );\n if (subtractedType) {\n result[typeName] = subtractedType;\n }\n }\n\n // Check for types in subtrahend that don't exist in minuend\n for (const typeName of Object.keys(subtrahend)) {\n if (!(typeName in minuend)) {\n if (strict) {\n throw new Error(`Type ${typeName} does not exist in minuend`);\n }\n // In non-strict mode, ignore missing types\n }\n }\n\n return result;\n}\n\n/**\n * Subtracts a single type definition.\n */\nfunction subtractType(\n typeName: string,\n minuendDef: TypeDefinitionTuple,\n subtrahendDef: TypeDefinitionTuple,\n strict: boolean,\n): TypeDefinitionTuple | null {\n if (\n isObjectTypeDefinition(minuendDef) &&\n isObjectTypeDefinition(subtrahendDef)\n ) {\n const subtractedFields = subtractFields(\n typeName,\n getFields(minuendDef),\n getFields(subtrahendDef),\n strict,\n );\n if (Object.keys(subtractedFields).length === 0) {\n return null; // All fields removed\n }\n const interfaces = getObjectTypeInterfaces(minuendDef);\n return createObjectTypeDefinition(\n subtractedFields,\n interfaces.length > 0 ? interfaces : undefined,\n );\n }\n\n if (\n isInterfaceTypeDefinition(minuendDef) &&\n isInterfaceTypeDefinition(subtrahendDef)\n ) {\n const subtractedFields = subtractFields(\n typeName,\n getFields(minuendDef),\n getFields(subtrahendDef),\n strict,\n );\n if (Object.keys(subtractedFields).length === 0) {\n return null; // All fields removed\n }\n const interfaces = getInterfaceTypeInterfaces(minuendDef);\n return createInterfaceTypeDefinition(\n subtractedFields,\n interfaces.length > 0 ? interfaces : undefined,\n );\n }\n\n if (\n isInputObjectTypeDefinition(minuendDef) &&\n isInputObjectTypeDefinition(subtrahendDef)\n ) {\n const subtractedFields = subtractInputFields(\n typeName,\n getInputObjectFields(minuendDef),\n getInputObjectFields(subtrahendDef),\n strict,\n );\n if (Object.keys(subtractedFields).length === 0) {\n return null; // All fields removed\n }\n return createInputObjectTypeDefinition(subtractedFields);\n }\n\n if (\n isUnionTypeDefinition(minuendDef) &&\n isUnionTypeDefinition(subtrahendDef)\n ) {\n const subtractedMembers = subtractUnionMembers(\n typeName,\n getUnionTypeMembers(minuendDef),\n getUnionTypeMembers(subtrahendDef),\n strict,\n );\n if (subtractedMembers.length === 0) {\n return null; // All members removed\n }\n return createUnionTypeDefinition(subtractedMembers);\n }\n\n if (isEnumTypeDefinition(minuendDef) && isEnumTypeDefinition(subtrahendDef)) {\n const subtractedValues = subtractEnumValues(\n typeName,\n getEnumValues(minuendDef),\n getEnumValues(subtrahendDef),\n strict,\n );\n if (subtractedValues.length === 0) {\n return null; // All values removed\n }\n return createEnumTypeDefinition(subtractedValues);\n }\n\n if (\n isScalarTypeDefinition(minuendDef) &&\n isScalarTypeDefinition(subtrahendDef)\n ) {\n // Scalars are atomic - if subtrahend has it, remove entire scalar\n return null;\n }\n\n return null;\n}\n\n/**\n * Subtracts fields from object/interface types.\n */\nfunction subtractFields(\n typeName: string,\n minuendFields: FieldDefinitionRecord,\n subtrahendFields: FieldDefinitionRecord,\n strict: boolean,\n): FieldDefinitionRecord {\n const result: FieldDefinitionRecord = {};\n\n for (const [fieldName, minuendField] of Object.entries(minuendFields)) {\n const subtrahendField = subtrahendFields[fieldName];\n\n if (!subtrahendField) {\n // Field doesn't exist in subtrahend, keep it\n result[fieldName] = minuendField;\n continue;\n }\n\n // Validate field types match\n const minuendType = getFieldTypeReference(minuendField);\n const subtrahendType = getFieldTypeReference(subtrahendField);\n if (minuendType !== subtrahendType) {\n throw new Error(\n `Field ${typeName}.${fieldName} has different type: ${inspect(\n minuendType,\n )} vs ${inspect(subtrahendType)}`,\n );\n }\n\n // Validate field arguments match exactly\n const minuendArgs = getFieldArgs(minuendField);\n const subtrahendArgs = getFieldArgs(subtrahendField);\n\n // Both must have same argument structure\n if (!minuendArgs && !subtrahendArgs) {\n // Both have no arguments, field can be subtracted\n } else if (!minuendArgs || !subtrahendArgs) {\n // One has args, other doesn't - not exact match\n throw new Error(\n `Field arguments must match exactly for subtraction. Field ${typeName}.${fieldName} has different argument structures.`,\n );\n } else {\n // Both have arguments, compare them\n const minuendArgKeys = Object.keys(minuendArgs).sort();\n const subtrahendArgKeys = Object.keys(subtrahendArgs).sort();\n\n if (\n minuendArgKeys.length !== subtrahendArgKeys.length ||\n !minuendArgKeys.every((key, index) => key === subtrahendArgKeys[index])\n ) {\n throw new Error(\n `Field arguments must match exactly for subtraction. Field ${typeName}.${fieldName} has different argument keys.`,\n );\n }\n\n // Check each argument type matches\n for (const argName of minuendArgKeys) {\n const minuendArgType = getInputValueTypeReference(minuendArgs[argName]);\n const subtrahendArgType = getInputValueTypeReference(\n subtrahendArgs[argName],\n );\n if (minuendArgType !== subtrahendArgType) {\n throw new Error(\n `Field arguments must match exactly for subtraction. Field ${typeName}.${fieldName} argument ${argName} has different types.`,\n );\n }\n }\n }\n\n // Field exists in subtrahend and matches exactly, remove it\n }\n\n // Check for fields in subtrahend that don't exist in minuend\n for (const fieldName of Object.keys(subtrahendFields)) {\n if (!(fieldName in minuendFields)) {\n if (strict) {\n throw new Error(\n `Field ${typeName}.${fieldName} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing fields\n }\n }\n\n return result;\n}\n\n/**\n * Subtracts input fields from input object types.\n */\nfunction subtractInputFields(\n typeName: string,\n minuendFields: InputValueDefinitionRecord,\n subtrahendFields: InputValueDefinitionRecord,\n strict: boolean,\n): InputValueDefinitionRecord {\n const result: InputValueDefinitionRecord = {};\n\n for (const [fieldName, minuendField] of Object.entries(minuendFields)) {\n const subtrahendField = subtrahendFields[fieldName];\n\n if (!subtrahendField) {\n // Field doesn't exist in subtrahend, keep it\n result[fieldName] = minuendField;\n continue;\n }\n\n // Validate field types match\n const minuendType = getInputValueTypeReference(minuendField);\n const subtrahendType = getInputValueTypeReference(subtrahendField);\n if (minuendType !== subtrahendType) {\n throw new Error(\n `Input field ${typeName}.${fieldName} has different type: ${inspect(\n minuendType,\n )} vs ${inspect(subtrahendType)}`,\n );\n }\n\n // Field exists in subtrahend, remove it\n }\n\n // Check for fields in subtrahend that don't exist in minuend\n for (const fieldName of Object.keys(subtrahendFields)) {\n if (!(fieldName in minuendFields)) {\n if (strict) {\n throw new Error(\n `Input field ${typeName}.${fieldName} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing fields\n }\n }\n\n return result;\n}\n\n/**\n * Subtracts union members.\n */\nfunction subtractUnionMembers(\n typeName: string,\n minuendMembers: string[],\n subtrahendMembers: string[],\n strict: boolean,\n): string[] {\n // Union types must match exactly for subtraction\n const minuendSet = new Set(minuendMembers);\n const subtrahendSet = new Set(subtrahendMembers);\n\n // Check if they have the same members\n if (\n minuendMembers.length === subtrahendMembers.length &&\n minuendMembers.every((member) => subtrahendSet.has(member))\n ) {\n // Exact match - remove the entire union\n return [];\n }\n\n // Check for members in subtrahend that don't exist in minuend\n for (const member of subtrahendMembers) {\n if (!minuendSet.has(member)) {\n if (strict) {\n throw new Error(\n `Union ${typeName}: member ${member} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing members and keep the original union\n return minuendMembers;\n }\n }\n\n // If we get here, all subtrahend members exist in minuend but they don't match exactly\n throw new Error(\n `Union types must match exactly for subtraction. Union ${typeName} has different member sets.`,\n );\n}\n\n/**\n * Subtracts enum values.\n */\nfunction subtractEnumValues(\n typeName: string,\n minuendValues: string[],\n subtrahendValues: string[],\n strict: boolean,\n): string[] {\n // Enum types must match exactly for subtraction\n const minuendSet = new Set(minuendValues);\n const subtrahendSet = new Set(subtrahendValues);\n\n // Check if they have the same values\n if (\n minuendValues.length === subtrahendValues.length &&\n minuendValues.every((value) => subtrahendSet.has(value))\n ) {\n // Exact match - remove the entire enum\n return [];\n }\n\n // Check for values in subtrahend that don't exist in minuend\n for (const value of subtrahendValues) {\n if (!minuendSet.has(value)) {\n if (strict) {\n throw new Error(\n `Enum ${typeName}: value ${value} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing values and keep the original enum\n return minuendValues;\n }\n }\n\n // If we get here, all subtrahend values exist in minuend but they don't match exactly\n throw new Error(\n `Enum types must match exactly for subtraction. Enum ${typeName} has different value sets.`,\n );\n}\n\n/**\n * Subtracts directives.\n */\nfunction subtractDirectives(\n minuendDirectives: DirectiveDefinitionTuple[],\n subtrahendDirectives: DirectiveDefinitionTuple[],\n strict: boolean,\n): DirectiveDefinitionTuple[] {\n const result: DirectiveDefinitionTuple[] = [];\n\n for (const minuendDirective of minuendDirectives) {\n const minuendName = getDirectiveName(minuendDirective);\n const subtrahendDirective = subtrahendDirectives.find(\n (d) => getDirectiveName(d) === minuendName,\n );\n\n if (!subtrahendDirective) {\n // Directive doesn't exist in subtrahend, keep it\n result.push(minuendDirective);\n continue;\n }\n\n // Directive exists, check arguments\n const minuendArgs = getDirectiveDefinitionArgs(minuendDirective);\n const subtrahendArgs = getDirectiveDefinitionArgs(subtrahendDirective);\n\n if (!minuendArgs && !subtrahendArgs) {\n // Both have no arguments, remove entire directive\n continue;\n }\n\n if (!minuendArgs || !subtrahendArgs) {\n // One has args, other doesn't - arguments don't match exactly\n throw new Error(\n `Directive arguments must match exactly for subtraction. Directive ${minuendName} has different argument structures.`,\n );\n }\n\n // Both have arguments, check if they match exactly\n const minuendArgKeys = Object.keys(minuendArgs).sort();\n const subtrahendArgKeys = Object.keys(subtrahendArgs).sort();\n\n if (\n minuendArgKeys.length !== subtrahendArgKeys.length ||\n !minuendArgKeys.every((key, index) => key === subtrahendArgKeys[index])\n ) {\n throw new Error(\n `Directive arguments must match exactly for subtraction. Directive ${minuendName} has different argument keys.`,\n );\n }\n\n // Check each argument type matches\n for (const argName of minuendArgKeys) {\n const minuendArgType = getInputValueTypeReference(minuendArgs[argName]);\n const subtrahendArgType = getInputValueTypeReference(\n subtrahendArgs[argName],\n );\n if (minuendArgType !== subtrahendArgType) {\n throw new Error(\n `Directive arguments must match exactly for subtraction. Directive ${minuendName} argument ${argName} has different types.`,\n );\n }\n }\n\n // Arguments match exactly, remove entire directive\n }\n\n // Check for directives in subtrahend that don't exist in minuend\n for (const subtrahendDirective of subtrahendDirectives) {\n const subtrahendName = getDirectiveName(subtrahendDirective);\n const exists = minuendDirectives.some(\n (d) => getDirectiveName(d) === subtrahendName,\n );\n if (!exists) {\n if (strict) {\n throw new Error(\n `Directive ${subtrahendName} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing directives\n }\n }\n\n return result;\n}\n"],
5
- "mappings": ";AACA;AAAA,EAOE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AAWjB,SAAS,0BACd,SACA,YACA,SAAS,OACU;AACnB,QAAM,SAA4B;AAAA,IAChC,OAAO,CAAC;AAAA,IACR,YAAY,CAAC;AAAA,EACf;AAGA,MAAI,QAAQ,SAAS,WAAW,OAAO;AACrC,WAAO,QAAQ,cAAc,QAAQ,OAA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vE;AAAA,IACF;AAGA,UAAM,iBAAiB,OAAO,KAAK,WAAW,EAAE,KAAK;AACrD,UAAM,oBAAoB,OAAO,KAAK,cAAc,EAAE,KAAK;AAE3D,QACE,eAAe,WAAW,kBAAkB,UAC5C,CAAC,eAAe,MAAM,CAAC,KAAK,UAAU,QAAQ,kBAAkB,KAAK,CAAC,GACtE;AACA,YAAM,IAAI;AAAA,QACR,qEAAqE;AAAA,MACvE;AAAA,IACF;AAGA,eAAW,WAAW,gBAAgB;AACpC,YAAM,iBAAiB,2BAA2B,YAAY,OAAO,CAAC;AACtE,YAAM,oBAAoB;AAAA,QACxB,eAAe,OAAO;AAAA,MACxB;AACA,UAAI,mBAAmB,mBAAmB;AACxC,cAAM,IAAI;AAAA,UACR,qEAAqE,wBAAwB;AAAA,QAC/F;AAAA,MACF;AAAA,IACF;AAAA,EAGF;AAGA,aAAW,uBAAuB,sBAAsB;AACtD,UAAM,iBAAiB,iBAAiB,mBAAmB;AAC3D,UAAM,SAAS,kBAAkB;AAAA,MAC/B,CAAC,MAAM,iBAAiB,CAAC,MAAM;AAAA,IACjC;AACA,QAAI,CAAC,QAAQ;AACX,UAAI,QAAQ;AACV,cAAM,IAAI;AAAA,UACR,aAAa;AAAA,QACf;AAAA,MACF;AAAA,IAEF;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["// Note: this utility is vibe-coded. Use at your own risk! :)\nimport {\n SchemaDefinitions,\n DirectiveDefinitionTuple,\n FieldDefinitionRecord,\n InputValueDefinitionRecord,\n TypeDefinitionsRecord,\n TypeDefinitionTuple,\n getDirectiveDefinitionArgs,\n getDirectiveDefinitionName,\n getEnumValues,\n getFieldTypeReference,\n getFieldArgs,\n getFields,\n getInputObjectFields,\n getInputValueTypeReference,\n getUnionTypeMembers,\n isEnumTypeDefinition,\n isInputObjectTypeDefinition,\n isInterfaceTypeDefinition,\n isObjectTypeDefinition,\n isScalarTypeDefinition,\n isUnionTypeDefinition,\n createEnumTypeDefinition,\n createInputObjectTypeDefinition,\n createInterfaceTypeDefinition,\n createObjectTypeDefinition,\n createUnionTypeDefinition,\n getObjectTypeInterfaces,\n getInterfaceTypeInterfaces,\n} from \"../schema/definition\";\nimport { inspect } from \"../jsutils/inspect\";\n\n/**\n * Subtracts schema definitions from minuend that exist in subtrahend.\n * Returns a new SchemaDefinitions object without mutating inputs.\n *\n * @param minuend - The schema definitions to subtract from\n * @param subtrahend - The schema definitions to subtract\n * @param strict - If true, throws errors on items in subtrahend that are not in minuend; if false, ignores them\n * @returns A new SchemaDefinitions with elements from minuend not in subtrahend\n */\nexport function subtractSchemaDefinitions(\n minuend: SchemaDefinitions,\n subtrahend: SchemaDefinitions,\n strict = false,\n): SchemaDefinitions {\n const result: SchemaDefinitions = {\n types: {},\n directives: [],\n };\n\n // Subtract types\n if (minuend.types && subtrahend.types) {\n result.types = subtractTypes(minuend.types, subtrahend.types, strict);\n } else if (minuend.types) {\n result.types = { ...minuend.types };\n }\n\n // Subtract directives\n if (minuend.directives && subtrahend.directives) {\n result.directives = subtractDirectives(\n minuend.directives,\n subtrahend.directives,\n strict,\n );\n } else if (minuend.directives) {\n result.directives = [...minuend.directives];\n }\n\n return result;\n}\n\n/**\n * Subtracts types from minuend that exist in subtrahend.\n */\nfunction subtractTypes(\n minuend: TypeDefinitionsRecord,\n subtrahend: TypeDefinitionsRecord,\n strict: boolean,\n): TypeDefinitionsRecord {\n const result: TypeDefinitionsRecord = {};\n\n for (const [typeName, minuendDef] of Object.entries(minuend)) {\n const subtrahendDef = subtrahend[typeName];\n\n if (!subtrahendDef) {\n // Type doesn't exist in subtrahend, keep it\n result[typeName] = minuendDef;\n continue;\n }\n\n // Validate type kinds match\n if (minuendDef[0] !== subtrahendDef[0]) {\n throw new Error(\n `Type ${typeName} is represented differently in different schema fragments:\\n` +\n inspect(minuendDef) +\n `\\n` +\n inspect(subtrahendDef),\n );\n }\n\n // Handle different type kinds\n const subtractedType = subtractType(\n typeName,\n minuendDef,\n subtrahendDef,\n strict,\n );\n if (subtractedType) {\n result[typeName] = subtractedType;\n }\n }\n\n // Check for types in subtrahend that don't exist in minuend\n for (const typeName of Object.keys(subtrahend)) {\n if (!(typeName in minuend)) {\n if (strict) {\n throw new Error(`Type ${typeName} does not exist in minuend`);\n }\n // In non-strict mode, ignore missing types\n }\n }\n\n return result;\n}\n\n/**\n * Subtracts a single type definition.\n */\nfunction subtractType(\n typeName: string,\n minuendDef: TypeDefinitionTuple,\n subtrahendDef: TypeDefinitionTuple,\n strict: boolean,\n): TypeDefinitionTuple | null {\n if (\n isObjectTypeDefinition(minuendDef) &&\n isObjectTypeDefinition(subtrahendDef)\n ) {\n const subtractedFields = subtractFields(\n typeName,\n getFields(minuendDef),\n getFields(subtrahendDef),\n strict,\n );\n if (Object.keys(subtractedFields).length === 0) {\n return null; // All fields removed\n }\n const interfaces = getObjectTypeInterfaces(minuendDef);\n return createObjectTypeDefinition(\n subtractedFields,\n interfaces.length > 0 ? interfaces : undefined,\n );\n }\n\n if (\n isInterfaceTypeDefinition(minuendDef) &&\n isInterfaceTypeDefinition(subtrahendDef)\n ) {\n const subtractedFields = subtractFields(\n typeName,\n getFields(minuendDef),\n getFields(subtrahendDef),\n strict,\n );\n if (Object.keys(subtractedFields).length === 0) {\n return null; // All fields removed\n }\n const interfaces = getInterfaceTypeInterfaces(minuendDef);\n return createInterfaceTypeDefinition(\n subtractedFields,\n interfaces.length > 0 ? interfaces : undefined,\n );\n }\n\n if (\n isInputObjectTypeDefinition(minuendDef) &&\n isInputObjectTypeDefinition(subtrahendDef)\n ) {\n const subtractedFields = subtractInputFields(\n typeName,\n getInputObjectFields(minuendDef),\n getInputObjectFields(subtrahendDef),\n strict,\n );\n if (Object.keys(subtractedFields).length === 0) {\n return null; // All fields removed\n }\n return createInputObjectTypeDefinition(subtractedFields);\n }\n\n if (\n isUnionTypeDefinition(minuendDef) &&\n isUnionTypeDefinition(subtrahendDef)\n ) {\n const subtractedMembers = subtractUnionMembers(\n typeName,\n getUnionTypeMembers(minuendDef),\n getUnionTypeMembers(subtrahendDef),\n strict,\n );\n if (subtractedMembers.length === 0) {\n return null; // All members removed\n }\n return createUnionTypeDefinition(subtractedMembers);\n }\n\n if (isEnumTypeDefinition(minuendDef) && isEnumTypeDefinition(subtrahendDef)) {\n const subtractedValues = subtractEnumValues(\n typeName,\n getEnumValues(minuendDef),\n getEnumValues(subtrahendDef),\n strict,\n );\n if (subtractedValues.length === 0) {\n return null; // All values removed\n }\n return createEnumTypeDefinition(subtractedValues);\n }\n\n if (\n isScalarTypeDefinition(minuendDef) &&\n isScalarTypeDefinition(subtrahendDef)\n ) {\n // Scalars are atomic - if subtrahend has it, remove entire scalar\n return null;\n }\n\n return null;\n}\n\n/**\n * Subtracts fields from object/interface types.\n */\nfunction subtractFields(\n typeName: string,\n minuendFields: FieldDefinitionRecord,\n subtrahendFields: FieldDefinitionRecord,\n strict: boolean,\n): FieldDefinitionRecord {\n const result: FieldDefinitionRecord = {};\n\n for (const [fieldName, minuendField] of Object.entries(minuendFields)) {\n const subtrahendField = subtrahendFields[fieldName];\n\n if (!subtrahendField) {\n // Field doesn't exist in subtrahend, keep it\n result[fieldName] = minuendField;\n continue;\n }\n\n // Validate field types match\n const minuendType = getFieldTypeReference(minuendField);\n const subtrahendType = getFieldTypeReference(subtrahendField);\n if (minuendType !== subtrahendType) {\n throw new Error(\n `Field ${typeName}.${fieldName} has different type: ${inspect(\n minuendType,\n )} vs ${inspect(subtrahendType)}`,\n );\n }\n\n // Validate field arguments match exactly\n const minuendArgs = getFieldArgs(minuendField);\n const subtrahendArgs = getFieldArgs(subtrahendField);\n\n // Both must have same argument structure\n if (!minuendArgs && !subtrahendArgs) {\n // Both have no arguments, field can be subtracted\n } else if (!minuendArgs || !subtrahendArgs) {\n // One has args, other doesn't - not exact match\n throw new Error(\n `Field arguments must match exactly for subtraction. Field ${typeName}.${fieldName} has different argument structures.`,\n );\n } else {\n // Both have arguments, compare them\n const minuendArgKeys = Object.keys(minuendArgs).sort();\n const subtrahendArgKeys = Object.keys(subtrahendArgs).sort();\n\n if (\n minuendArgKeys.length !== subtrahendArgKeys.length ||\n !minuendArgKeys.every((key, index) => key === subtrahendArgKeys[index])\n ) {\n throw new Error(\n `Field arguments must match exactly for subtraction. Field ${typeName}.${fieldName} has different argument keys.`,\n );\n }\n\n // Check each argument type matches\n for (const argName of minuendArgKeys) {\n const minuendArgType = getInputValueTypeReference(minuendArgs[argName]);\n const subtrahendArgType = getInputValueTypeReference(\n subtrahendArgs[argName],\n );\n if (minuendArgType !== subtrahendArgType) {\n throw new Error(\n `Field arguments must match exactly for subtraction. Field ${typeName}.${fieldName} argument ${argName} has different types.`,\n );\n }\n }\n }\n\n // Field exists in subtrahend and matches exactly, remove it\n }\n\n // Check for fields in subtrahend that don't exist in minuend\n for (const fieldName of Object.keys(subtrahendFields)) {\n if (!(fieldName in minuendFields)) {\n if (strict) {\n throw new Error(\n `Field ${typeName}.${fieldName} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing fields\n }\n }\n\n return result;\n}\n\n/**\n * Subtracts input fields from input object types.\n */\nfunction subtractInputFields(\n typeName: string,\n minuendFields: InputValueDefinitionRecord,\n subtrahendFields: InputValueDefinitionRecord,\n strict: boolean,\n): InputValueDefinitionRecord {\n const result: InputValueDefinitionRecord = {};\n\n for (const [fieldName, minuendField] of Object.entries(minuendFields)) {\n const subtrahendField = subtrahendFields[fieldName];\n\n if (!subtrahendField) {\n // Field doesn't exist in subtrahend, keep it\n result[fieldName] = minuendField;\n continue;\n }\n\n // Validate field types match\n const minuendType = getInputValueTypeReference(minuendField);\n const subtrahendType = getInputValueTypeReference(subtrahendField);\n if (minuendType !== subtrahendType) {\n throw new Error(\n `Input field ${typeName}.${fieldName} has different type: ${inspect(\n minuendType,\n )} vs ${inspect(subtrahendType)}`,\n );\n }\n\n // Field exists in subtrahend, remove it\n }\n\n // Check for fields in subtrahend that don't exist in minuend\n for (const fieldName of Object.keys(subtrahendFields)) {\n if (!(fieldName in minuendFields)) {\n if (strict) {\n throw new Error(\n `Input field ${typeName}.${fieldName} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing fields\n }\n }\n\n return result;\n}\n\n/**\n * Subtracts union members.\n */\nfunction subtractUnionMembers(\n typeName: string,\n minuendMembers: string[],\n subtrahendMembers: string[],\n strict: boolean,\n): string[] {\n // Union types must match exactly for subtraction\n const minuendSet = new Set(minuendMembers);\n const subtrahendSet = new Set(subtrahendMembers);\n\n // Check if they have the same members\n if (\n minuendMembers.length === subtrahendMembers.length &&\n minuendMembers.every((member) => subtrahendSet.has(member))\n ) {\n // Exact match - remove the entire union\n return [];\n }\n\n // Check for members in subtrahend that don't exist in minuend\n for (const member of subtrahendMembers) {\n if (!minuendSet.has(member)) {\n if (strict) {\n throw new Error(\n `Union ${typeName}: member ${member} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing members and keep the original union\n return minuendMembers;\n }\n }\n\n // If we get here, all subtrahend members exist in minuend but they don't match exactly\n throw new Error(\n `Union types must match exactly for subtraction. Union ${typeName} has different member sets.`,\n );\n}\n\n/**\n * Subtracts enum values.\n */\nfunction subtractEnumValues(\n typeName: string,\n minuendValues: string[],\n subtrahendValues: string[],\n strict: boolean,\n): string[] {\n // Enum types must match exactly for subtraction\n const minuendSet = new Set(minuendValues);\n const subtrahendSet = new Set(subtrahendValues);\n\n // Check if they have the same values\n if (\n minuendValues.length === subtrahendValues.length &&\n minuendValues.every((value) => subtrahendSet.has(value))\n ) {\n // Exact match - remove the entire enum\n return [];\n }\n\n // Check for values in subtrahend that don't exist in minuend\n for (const value of subtrahendValues) {\n if (!minuendSet.has(value)) {\n if (strict) {\n throw new Error(\n `Enum ${typeName}: value ${value} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing values and keep the original enum\n return minuendValues;\n }\n }\n\n // If we get here, all subtrahend values exist in minuend but they don't match exactly\n throw new Error(\n `Enum types must match exactly for subtraction. Enum ${typeName} has different value sets.`,\n );\n}\n\n/**\n * Subtracts directives.\n */\nfunction subtractDirectives(\n minuendDirectives: DirectiveDefinitionTuple[],\n subtrahendDirectives: DirectiveDefinitionTuple[],\n strict: boolean,\n): DirectiveDefinitionTuple[] {\n const result: DirectiveDefinitionTuple[] = [];\n\n for (const minuendDirective of minuendDirectives) {\n const minuendName = getDirectiveDefinitionName(minuendDirective);\n const subtrahendDirective = subtrahendDirectives.find(\n (d) => getDirectiveDefinitionName(d) === minuendName,\n );\n\n if (!subtrahendDirective) {\n // Directive doesn't exist in subtrahend, keep it\n result.push(minuendDirective);\n continue;\n }\n\n // Directive exists, check arguments\n const minuendArgs = getDirectiveDefinitionArgs(minuendDirective);\n const subtrahendArgs = getDirectiveDefinitionArgs(subtrahendDirective);\n\n if (!minuendArgs && !subtrahendArgs) {\n // Both have no arguments, remove entire directive\n continue;\n }\n\n if (!minuendArgs || !subtrahendArgs) {\n // One has args, other doesn't - arguments don't match exactly\n throw new Error(\n `Directive arguments must match exactly for subtraction. Directive ${minuendName} has different argument structures.`,\n );\n }\n\n // Both have arguments, check if they match exactly\n const minuendArgKeys = Object.keys(minuendArgs).sort();\n const subtrahendArgKeys = Object.keys(subtrahendArgs).sort();\n\n if (\n minuendArgKeys.length !== subtrahendArgKeys.length ||\n !minuendArgKeys.every((key, index) => key === subtrahendArgKeys[index])\n ) {\n throw new Error(\n `Directive arguments must match exactly for subtraction. Directive ${minuendName} has different argument keys.`,\n );\n }\n\n // Check each argument type matches\n for (const argName of minuendArgKeys) {\n const minuendArgType = getInputValueTypeReference(minuendArgs[argName]);\n const subtrahendArgType = getInputValueTypeReference(\n subtrahendArgs[argName],\n );\n if (minuendArgType !== subtrahendArgType) {\n throw new Error(\n `Directive arguments must match exactly for subtraction. Directive ${minuendName} argument ${argName} has different types.`,\n );\n }\n }\n\n // Arguments match exactly, remove entire directive\n }\n\n // Check for directives in subtrahend that don't exist in minuend\n for (const subtrahendDirective of subtrahendDirectives) {\n const subtrahendName = getDirectiveDefinitionName(subtrahendDirective);\n const exists = minuendDirectives.some(\n (d) => getDirectiveDefinitionName(d) === subtrahendName,\n );\n if (!exists) {\n if (strict) {\n throw new Error(\n `Directive ${subtrahendName} does not exist in minuend`,\n );\n }\n // In non-strict mode, ignore missing directives\n }\n }\n\n return result;\n}\n"],
5
+ "mappings": ";AACA;AAAA,EAOE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AAWjB,SAAS,0BACd,SACA,YACA,SAAS,OACU;AACnB,QAAM,SAA4B;AAAA,IAChC,OAAO,CAAC;AAAA,IACR,YAAY,CAAC;AAAA,EACf;AAGA,MAAI,QAAQ,SAAS,WAAW,OAAO;AACrC,WAAO,QAAQ,cAAc,QAAQ,OAAO,WAAW,OAAO,MAAM;AAAA,EACtE,WAAW,QAAQ,OAAO;AACxB,WAAO,QAAQ,EAAE,GAAG,QAAQ,MAAM;AAAA,EACpC;AAGA,MAAI,QAAQ,cAAc,WAAW,YAAY;AAC/C,WAAO,aAAa;AAAA,MAClB,QAAQ;AAAA,MACR,WAAW;AAAA,MACX;AAAA,IACF;AAAA,EACF,WAAW,QAAQ,YAAY;AAC7B,WAAO,aAAa,CAAC,GAAG,QAAQ,UAAU;AAAA,EAC5C;AAEA,SAAO;AACT;AAKA,SAAS,cACP,SACA,YACA,QACuB;AACvB,QAAM,SAAgC,CAAC;AAEvC,aAAW,CAAC,UAAU,UAAU,KAAK,OAAO,QAAQ,OAAO,GAAG;AAC5D,UAAM,gBAAgB,WAAW,QAAQ;AAEzC,QAAI,CAAC,eAAe;AAElB,aAAO,QAAQ,IAAI;AACnB;AAAA,IACF;AAGA,QAAI,WAAW,CAAC,MAAM,cAAc,CAA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A2B,mBAAmB;AACrE,UAAM,SAAS,kBAAkB;AAAA,MAC/B,CAAC,MAAM,2BAA2B,CAAC,MAAM;AAAA,IAC3C;AACA,QAAI,CAAC,QAAQ;AACX,UAAI,QAAQ;AACV,cAAM,IAAI;AAAA,UACR,aAAa;AAAA,QACf;AAAA,MACF;AAAA,IAEF;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/lib/values.js CHANGED
@@ -119,7 +119,7 @@ function getArgumentValues(exeContext, def, node) {
119
119
  var _a;
120
120
  const definitions = exeContext.schemaFragment.definitions;
121
121
  const coercedValues = {};
122
- const argumentDefs = node.kind === import_graphql.Kind.FIELD ? (0, import_definition.getFieldArguments)(def) : (0, import_definition.getDirectiveArguments)(def);
122
+ const argumentDefs = node.kind === import_graphql.Kind.FIELD ? (0, import_definition.getFieldArguments)(def) : (0, import_definition.getDirectiveDefinitionArgs)(def);
123
123
  if (!argumentDefs) {
124
124
  return coercedValues;
125
125
  }
@@ -190,7 +190,7 @@ function getArgumentValues(exeContext, def, node) {
190
190
  }
191
191
  function getDirectiveValues(exeContext, directiveDef, node) {
192
192
  var _a;
193
- const name = (0, import_definition.getDirectiveName)(directiveDef);
193
+ const name = (0, import_definition.getDirectiveDefinitionName)(directiveDef);
194
194
  const directiveNode = (_a = node.directives) == null ? void 0 : _a.find(
195
195
  (directive) => directive.name.value === name
196
196
  );
package/lib/values.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/values.ts"],
4
- "sourcesContent": ["import {\n GraphQLError,\n Kind,\n print,\n locatedError,\n DirectiveNode,\n FieldNode,\n VariableDefinitionNode,\n} from \"graphql\";\nimport { inspect } from \"./jsutils/inspect\";\nimport { printPathArray } from \"./jsutils/printPathArray\";\nimport { ExecutionContext } from \"./executeWithoutSchema\";\nimport {\n DirectiveDefinitionTuple,\n FieldDefinition,\n getFieldArguments,\n getDirectiveName,\n getInputDefaultValue,\n getInputValueTypeReference,\n isDefined,\n isInputType,\n getDirectiveArguments,\n} from \"./schema/definition\";\nimport { valueFromAST } from \"./utilities/valueFromAST\";\nimport { coerceInputValue } from \"./utilities/coerceInputValue\";\nimport {\n inspectTypeReference,\n isNonNullType,\n typeReferenceFromNode,\n} from \"./schema/reference\";\nimport type { SchemaFragment } from \"./types\";\n\ntype CoercedVariableValues =\n | { errors: Array<GraphQLError>; coerced?: never }\n | { coerced: { [variable: string]: unknown }; errors?: never };\n\n/**\n * Prepares an object map of variableValues of the correct type based on the\n * provided variable definitions and arbitrary input. If the input cannot be\n * parsed to match the variable definitions, a GraphQLError will be thrown.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getVariableValues(\n schemaFragment: SchemaFragment,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n inputs: { [variable: string]: unknown },\n options?: { maxErrors?: number },\n): CoercedVariableValues {\n const errors: GraphQLError[] = [];\n const maxErrors = options?.maxErrors;\n try {\n const coerced = coerceVariableValues(\n schemaFragment,\n varDefNodes,\n inputs,\n (error) => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw locatedError(\n \"Too many errors processing variables, error limit reached. Execution aborted.\",\n [],\n );\n }\n errors.push(error);\n },\n );\n\n if (errors.length === 0) {\n return { coerced };\n }\n } catch (error) {\n errors.push(error as GraphQLError);\n }\n\n return { errors: errors };\n}\n\nfunction coerceVariableValues(\n schemaFragment: SchemaFragment,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n inputs: { [variable: string]: unknown },\n onError: (error: GraphQLError) => void,\n): { [variable: string]: unknown } {\n const coercedValues: { [variable: string]: unknown } = {};\n for (const varDefNode of varDefNodes) {\n const varName = varDefNode.variable.name.value;\n const varTypeReference = typeReferenceFromNode(varDefNode.type);\n\n if (!isInputType(schemaFragment.definitions, varTypeReference)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n const varTypeStr = inspectTypeReference(varTypeReference);\n onError(\n locatedError(\n `Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`,\n [varDefNode.type],\n ),\n );\n continue;\n }\n\n if (!hasOwnProperty(inputs, varName)) {\n if (varDefNode.defaultValue) {\n coercedValues[varName] = valueFromAST(\n varDefNode.defaultValue,\n varTypeReference,\n schemaFragment,\n );\n } else if (isNonNullType(varTypeReference)) {\n const varTypeStr = inspectTypeReference(varTypeReference);\n onError(\n locatedError(\n `Variable \"$${varName}\" of required type \"${varTypeStr}\" was not provided.`,\n [varDefNode],\n ),\n );\n }\n continue;\n }\n\n const value = inputs[varName];\n if (value === null && isNonNullType(varTypeReference)) {\n const varTypeStr = inspectTypeReference(varTypeReference);\n onError(\n locatedError(\n `Variable \"$${varName}\" of non-null type \"${varTypeStr}\" must not be null.`,\n [varDefNode],\n ),\n );\n continue;\n }\n\n coercedValues[varName] = coerceInputValue(\n value,\n varTypeReference,\n schemaFragment,\n (path, invalidValue, error) => {\n let prefix =\n `Variable \"$${varName}\" got invalid value ` + inspect(invalidValue);\n if (path.length > 0) {\n prefix += ` at \"${varName}${printPathArray(path)}\"`;\n }\n onError(locatedError(prefix + \"; \" + error.message, [varDefNode]));\n },\n );\n }\n\n return coercedValues;\n}\n\n/**\n * Prepares an object map of argument values given a list of argument\n * definitions and list of argument AST nodes.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getArgumentValues(\n exeContext: ExecutionContext,\n def: FieldDefinition | DirectiveDefinitionTuple,\n node: FieldNode | DirectiveNode,\n): { [argument: string]: unknown } {\n const definitions = exeContext.schemaFragment.definitions;\n const coercedValues: { [argument: string]: unknown } = {};\n const argumentDefs =\n node.kind === Kind.FIELD\n ? getFieldArguments(def as FieldDefinition)\n : getDirectiveArguments(def as DirectiveDefinitionTuple);\n if (!argumentDefs) {\n return coercedValues;\n }\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argumentNodes = node.arguments ?? [];\n const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg]));\n\n for (const [name, argumentDef] of Object.entries(argumentDefs)) {\n const argumentNode = argNodeMap.get(name);\n const argumentTypeRef = getInputValueTypeReference(argumentDef);\n const defaultValue = getInputDefaultValue(argumentDef);\n\n if (argumentNode == null) {\n if (defaultValue !== undefined) {\n coercedValues[name] = defaultValue;\n } else if (isNonNullType(argumentTypeRef)) {\n const type = inspectTypeReference(argumentTypeRef);\n throw locatedError(\n `Argument \"${name}\" of required type \"${type}\" was not provided.`,\n [node],\n );\n }\n continue;\n }\n\n if (!isDefined(definitions, argumentTypeRef)) {\n throw locatedError(\n `Could not find type for argument ${name} in ${node.kind} ${node.name.value}`,\n [argumentNode],\n );\n }\n\n // if (!schemaTypes.isInputType(argumentTypeRef)) {\n // const type = schemaTypes.printTypeRef(argumentTypeRef);\n // throw locatedError(\n // `Argument \"$${name}\" expected value of type \"${type}\" which cannot be used as an input type.`,\n // [argumentNode],\n // );\n // }\n\n const valueNode = argumentNode.value;\n let isNull = valueNode.kind === Kind.NULL;\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n if (\n exeContext.variableValues == null ||\n !hasOwnProperty(exeContext.variableValues, variableName)\n ) {\n if (defaultValue !== undefined) {\n coercedValues[name] = defaultValue;\n } else if (isNonNullType(argumentTypeRef)) {\n const type = inspectTypeReference(argumentTypeRef);\n throw locatedError(\n `Argument \"${name}\" of required type \"${type}\" ` +\n `was provided the variable \"$${variableName}\" which was not provided a runtime value.`,\n [valueNode],\n );\n }\n continue;\n }\n isNull = exeContext.variableValues[variableName] == null;\n }\n\n if (isNull && isNonNullType(argumentTypeRef)) {\n const type = inspectTypeReference(argumentTypeRef);\n throw locatedError(\n `Argument \"${name}\" of non-null type \"${type}\" must not be null.\"`,\n [valueNode],\n );\n }\n\n const coercedValue = valueFromAST(\n valueNode,\n argumentTypeRef,\n exeContext.schemaFragment,\n exeContext.variableValues,\n );\n if (coercedValue === undefined) {\n // Note: ValuesOfCorrectTypeRule validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n throw locatedError(\n `Argument \"${name}\" has invalid value ${print(valueNode)}.`,\n [valueNode],\n );\n }\n coercedValues[name] = coercedValue;\n }\n\n return coercedValues;\n}\n\n/**\n * Prepares an object map of argument values given a directive definition\n * and a AST node which may contain directives. Optionally also accepts a map\n * of variable values.\n *\n * If the directive does not exist on the node, returns undefined.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getDirectiveValues(\n exeContext: ExecutionContext,\n directiveDef: DirectiveDefinitionTuple,\n node: { directives?: ReadonlyArray<DirectiveNode> },\n): undefined | { [argument: string]: unknown } {\n const name = getDirectiveName(directiveDef);\n\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const directiveNode = node.directives?.find(\n (directive) => directive.name.value === name,\n );\n\n if (directiveNode) {\n return getArgumentValues(exeContext, directiveDef, directiveNode);\n }\n}\n\nfunction hasOwnProperty(obj: unknown, prop: string): boolean {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAQO;AACP,qBAAwB;AACxB,4BAA+B;AAE/B,wBAUO;AACP,0BAA6B;AAC7B,8BAAiC;AACjC,uBAIO;AAkBA,SAAS,kBACd,gBACA,aACA,QACA,SACuB;AACvB,QAAM,SAAyB,CAAC;AAChC,QAAM,YAAY,mCAAS;AAC3B,MAAI;AACF,UAAM,UAAU;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA,CAAC,UAAU;AACT,YAAI,aAAa,QAAQ,OAAO,UAAU,WAAW;AACnD,oBAAM;AAAA,YACJ;AAAA,YACA,CAAC;AAAA,UACH;AAAA,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\n locatedError,\n DirectiveNode,\n FieldNode,\n VariableDefinitionNode,\n} from \"graphql\";\nimport { inspect } from \"./jsutils/inspect\";\nimport { printPathArray } from \"./jsutils/printPathArray\";\nimport { ExecutionContext } from \"./executeWithoutSchema\";\nimport {\n DirectiveDefinitionTuple,\n FieldDefinition,\n getFieldArguments,\n getDirectiveDefinitionName,\n getInputDefaultValue,\n getInputValueTypeReference,\n isDefined,\n isInputType,\n getDirectiveDefinitionArgs,\n} from \"./schema/definition\";\nimport { valueFromAST } from \"./utilities/valueFromAST\";\nimport { coerceInputValue } from \"./utilities/coerceInputValue\";\nimport {\n inspectTypeReference,\n isNonNullType,\n typeReferenceFromNode,\n} from \"./schema/reference\";\nimport type { SchemaFragment } from \"./types\";\n\ntype CoercedVariableValues =\n | { errors: Array<GraphQLError>; coerced?: never }\n | { coerced: { [variable: string]: unknown }; errors?: never };\n\n/**\n * Prepares an object map of variableValues of the correct type based on the\n * provided variable definitions and arbitrary input. If the input cannot be\n * parsed to match the variable definitions, a GraphQLError will be thrown.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getVariableValues(\n schemaFragment: SchemaFragment,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n inputs: { [variable: string]: unknown },\n options?: { maxErrors?: number },\n): CoercedVariableValues {\n const errors: GraphQLError[] = [];\n const maxErrors = options?.maxErrors;\n try {\n const coerced = coerceVariableValues(\n schemaFragment,\n varDefNodes,\n inputs,\n (error) => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw locatedError(\n \"Too many errors processing variables, error limit reached. Execution aborted.\",\n [],\n );\n }\n errors.push(error);\n },\n );\n\n if (errors.length === 0) {\n return { coerced };\n }\n } catch (error) {\n errors.push(error as GraphQLError);\n }\n\n return { errors: errors };\n}\n\nfunction coerceVariableValues(\n schemaFragment: SchemaFragment,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n inputs: { [variable: string]: unknown },\n onError: (error: GraphQLError) => void,\n): { [variable: string]: unknown } {\n const coercedValues: { [variable: string]: unknown } = {};\n for (const varDefNode of varDefNodes) {\n const varName = varDefNode.variable.name.value;\n const varTypeReference = typeReferenceFromNode(varDefNode.type);\n\n if (!isInputType(schemaFragment.definitions, varTypeReference)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n const varTypeStr = inspectTypeReference(varTypeReference);\n onError(\n locatedError(\n `Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`,\n [varDefNode.type],\n ),\n );\n continue;\n }\n\n if (!hasOwnProperty(inputs, varName)) {\n if (varDefNode.defaultValue) {\n coercedValues[varName] = valueFromAST(\n varDefNode.defaultValue,\n varTypeReference,\n schemaFragment,\n );\n } else if (isNonNullType(varTypeReference)) {\n const varTypeStr = inspectTypeReference(varTypeReference);\n onError(\n locatedError(\n `Variable \"$${varName}\" of required type \"${varTypeStr}\" was not provided.`,\n [varDefNode],\n ),\n );\n }\n continue;\n }\n\n const value = inputs[varName];\n if (value === null && isNonNullType(varTypeReference)) {\n const varTypeStr = inspectTypeReference(varTypeReference);\n onError(\n locatedError(\n `Variable \"$${varName}\" of non-null type \"${varTypeStr}\" must not be null.`,\n [varDefNode],\n ),\n );\n continue;\n }\n\n coercedValues[varName] = coerceInputValue(\n value,\n varTypeReference,\n schemaFragment,\n (path, invalidValue, error) => {\n let prefix =\n `Variable \"$${varName}\" got invalid value ` + inspect(invalidValue);\n if (path.length > 0) {\n prefix += ` at \"${varName}${printPathArray(path)}\"`;\n }\n onError(locatedError(prefix + \"; \" + error.message, [varDefNode]));\n },\n );\n }\n\n return coercedValues;\n}\n\n/**\n * Prepares an object map of argument values given a list of argument\n * definitions and list of argument AST nodes.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getArgumentValues(\n exeContext: ExecutionContext,\n def: FieldDefinition | DirectiveDefinitionTuple,\n node: FieldNode | DirectiveNode,\n): { [argument: string]: unknown } {\n const definitions = exeContext.schemaFragment.definitions;\n const coercedValues: { [argument: string]: unknown } = {};\n const argumentDefs =\n node.kind === Kind.FIELD\n ? getFieldArguments(def as FieldDefinition)\n : getDirectiveDefinitionArgs(def as DirectiveDefinitionTuple);\n if (!argumentDefs) {\n return coercedValues;\n }\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argumentNodes = node.arguments ?? [];\n const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg]));\n\n for (const [name, argumentDef] of Object.entries(argumentDefs)) {\n const argumentNode = argNodeMap.get(name);\n const argumentTypeRef = getInputValueTypeReference(argumentDef);\n const defaultValue = getInputDefaultValue(argumentDef);\n\n if (argumentNode == null) {\n if (defaultValue !== undefined) {\n coercedValues[name] = defaultValue;\n } else if (isNonNullType(argumentTypeRef)) {\n const type = inspectTypeReference(argumentTypeRef);\n throw locatedError(\n `Argument \"${name}\" of required type \"${type}\" was not provided.`,\n [node],\n );\n }\n continue;\n }\n\n if (!isDefined(definitions, argumentTypeRef)) {\n throw locatedError(\n `Could not find type for argument ${name} in ${node.kind} ${node.name.value}`,\n [argumentNode],\n );\n }\n\n // if (!schemaTypes.isInputType(argumentTypeRef)) {\n // const type = schemaTypes.printTypeRef(argumentTypeRef);\n // throw locatedError(\n // `Argument \"$${name}\" expected value of type \"${type}\" which cannot be used as an input type.`,\n // [argumentNode],\n // );\n // }\n\n const valueNode = argumentNode.value;\n let isNull = valueNode.kind === Kind.NULL;\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n if (\n exeContext.variableValues == null ||\n !hasOwnProperty(exeContext.variableValues, variableName)\n ) {\n if (defaultValue !== undefined) {\n coercedValues[name] = defaultValue;\n } else if (isNonNullType(argumentTypeRef)) {\n const type = inspectTypeReference(argumentTypeRef);\n throw locatedError(\n `Argument \"${name}\" of required type \"${type}\" ` +\n `was provided the variable \"$${variableName}\" which was not provided a runtime value.`,\n [valueNode],\n );\n }\n continue;\n }\n isNull = exeContext.variableValues[variableName] == null;\n }\n\n if (isNull && isNonNullType(argumentTypeRef)) {\n const type = inspectTypeReference(argumentTypeRef);\n throw locatedError(\n `Argument \"${name}\" of non-null type \"${type}\" must not be null.\"`,\n [valueNode],\n );\n }\n\n const coercedValue = valueFromAST(\n valueNode,\n argumentTypeRef,\n exeContext.schemaFragment,\n exeContext.variableValues,\n );\n if (coercedValue === undefined) {\n // Note: ValuesOfCorrectTypeRule validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n throw locatedError(\n `Argument \"${name}\" has invalid value ${print(valueNode)}.`,\n [valueNode],\n );\n }\n coercedValues[name] = coercedValue;\n }\n\n return coercedValues;\n}\n\n/**\n * Prepares an object map of argument values given a directive definition\n * and a AST node which may contain directives. Optionally also accepts a map\n * of variable values.\n *\n * If the directive does not exist on the node, returns undefined.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getDirectiveValues(\n exeContext: ExecutionContext,\n directiveDef: DirectiveDefinitionTuple,\n node: { directives?: ReadonlyArray<DirectiveNode> },\n): undefined | { [argument: string]: unknown } {\n const name = getDirectiveDefinitionName(directiveDef);\n\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const directiveNode = node.directives?.find(\n (directive) => directive.name.value === name,\n );\n\n if (directiveNode) {\n return getArgumentValues(exeContext, directiveDef, directiveNode);\n }\n}\n\nfunction hasOwnProperty(obj: unknown, prop: string): boolean {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAQO;AACP,qBAAwB;AACxB,4BAA+B;AAE/B,wBAUO;AACP,0BAA6B;AAC7B,8BAAiC;AACjC,uBAIO;AAkBA,SAAS,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