@graphitation/supermassive 3.0.0-alpha.1 → 3.0.0-alpha.4

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 (207) hide show
  1. package/.eslintcache +1 -1
  2. package/CHANGELOG.md +18 -2
  3. package/lib/__testUtils__/execute.d.ts +13 -0
  4. package/lib/__testUtils__/execute.d.ts.map +1 -0
  5. package/lib/__testUtils__/execute.js +203 -0
  6. package/lib/__testUtils__/execute.js.map +7 -0
  7. package/lib/__testUtils__/execute.mjs +181 -0
  8. package/lib/__testUtils__/execute.mjs.map +7 -0
  9. package/lib/__testUtils__/gql.d.ts +7 -0
  10. package/lib/__testUtils__/gql.d.ts.map +1 -0
  11. package/lib/{supermassive-ast/TypedAST.js → __testUtils__/gql.js} +8 -10
  12. package/lib/__testUtils__/gql.js.map +7 -0
  13. package/lib/__testUtils__/gql.mjs +8 -0
  14. package/lib/__testUtils__/gql.mjs.map +7 -0
  15. package/lib/benchmarks/index.js +15 -20
  16. package/lib/benchmarks/index.js.map +3 -3
  17. package/lib/benchmarks/index.mjs +16 -23
  18. package/lib/benchmarks/index.mjs.map +2 -2
  19. package/lib/collectFields.d.ts +4 -9
  20. package/lib/collectFields.d.ts.map +1 -1
  21. package/lib/collectFields.js +38 -99
  22. package/lib/collectFields.js.map +2 -2
  23. package/lib/collectFields.mjs +41 -100
  24. package/lib/collectFields.mjs.map +2 -2
  25. package/lib/executeWithSchema.d.ts +1 -1
  26. package/lib/executeWithSchema.d.ts.map +1 -1
  27. package/lib/executeWithSchema.js +27 -17
  28. package/lib/executeWithSchema.js.map +2 -2
  29. package/lib/executeWithSchema.mjs +32 -24
  30. package/lib/executeWithSchema.mjs.map +2 -2
  31. package/lib/executeWithoutSchema.d.ts +9 -5
  32. package/lib/executeWithoutSchema.d.ts.map +1 -1
  33. package/lib/executeWithoutSchema.js +217 -242
  34. package/lib/executeWithoutSchema.js.map +3 -3
  35. package/lib/executeWithoutSchema.mjs +225 -249
  36. package/lib/executeWithoutSchema.mjs.map +3 -3
  37. package/lib/index.d.ts +16 -11
  38. package/lib/index.d.ts.map +1 -1
  39. package/lib/index.js +24 -11
  40. package/lib/index.js.map +2 -2
  41. package/lib/index.mjs +32 -11
  42. package/lib/index.mjs.map +2 -2
  43. package/lib/schema/definition.d.ts +100 -0
  44. package/lib/schema/definition.d.ts.map +1 -0
  45. package/lib/schema/definition.js +77 -0
  46. package/lib/schema/definition.js.map +7 -0
  47. package/lib/schema/definition.mjs +58 -0
  48. package/lib/schema/definition.mjs.map +7 -0
  49. package/lib/schema/directives.d.ts +42 -0
  50. package/lib/schema/directives.d.ts.map +1 -0
  51. package/lib/schema/directives.js +87 -0
  52. package/lib/schema/directives.js.map +7 -0
  53. package/lib/schema/directives.mjs +70 -0
  54. package/lib/schema/directives.mjs.map +7 -0
  55. package/lib/schema/fragment.d.ts +63 -0
  56. package/lib/schema/fragment.d.ts.map +1 -0
  57. package/lib/schema/fragment.js +295 -0
  58. package/lib/schema/fragment.js.map +7 -0
  59. package/lib/schema/fragment.mjs +292 -0
  60. package/lib/schema/fragment.mjs.map +7 -0
  61. package/lib/schema/reference.d.ts +12 -0
  62. package/lib/schema/reference.d.ts.map +1 -0
  63. package/lib/schema/reference.js +137 -0
  64. package/lib/schema/reference.js.map +7 -0
  65. package/lib/schema/reference.mjs +118 -0
  66. package/lib/schema/reference.mjs.map +7 -0
  67. package/lib/schema/resolvers.d.ts +9 -0
  68. package/lib/schema/resolvers.d.ts.map +1 -0
  69. package/lib/schema/resolvers.js +47 -0
  70. package/lib/schema/resolvers.js.map +7 -0
  71. package/lib/schema/resolvers.mjs +35 -0
  72. package/lib/schema/resolvers.mjs.map +7 -0
  73. package/lib/subscribeWithSchema.d.ts +1 -1
  74. package/lib/subscribeWithSchema.d.ts.map +1 -1
  75. package/lib/subscribeWithSchema.js +27 -17
  76. package/lib/subscribeWithSchema.js.map +2 -2
  77. package/lib/subscribeWithSchema.mjs +32 -24
  78. package/lib/subscribeWithSchema.mjs.map +2 -2
  79. package/lib/types.d.ts +16 -27
  80. package/lib/types.d.ts.map +1 -1
  81. package/lib/types.js +0 -14
  82. package/lib/types.js.map +2 -2
  83. package/lib/types.mjs +0 -11
  84. package/lib/types.mjs.map +3 -3
  85. package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts +12 -0
  86. package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts.map +1 -0
  87. package/lib/utilities/addMinimalViableSchemaToRequestDocument.js +116 -0
  88. package/lib/utilities/addMinimalViableSchemaToRequestDocument.js.map +7 -0
  89. package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs +105 -0
  90. package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs.map +7 -0
  91. package/lib/utilities/annotateDocumentGraphQLTransform.d.ts +4 -0
  92. package/lib/utilities/annotateDocumentGraphQLTransform.d.ts.map +1 -0
  93. package/lib/{supermassive-ast → utilities}/annotateDocumentGraphQLTransform.js +3 -10
  94. package/lib/utilities/annotateDocumentGraphQLTransform.js.map +7 -0
  95. package/lib/utilities/annotateDocumentGraphQLTransform.mjs +10 -0
  96. package/lib/utilities/annotateDocumentGraphQLTransform.mjs.map +7 -0
  97. package/lib/utilities/coerceInputValue.d.ts +10 -0
  98. package/lib/utilities/coerceInputValue.d.ts.map +1 -0
  99. package/lib/utilities/coerceInputValue.js +181 -0
  100. package/lib/utilities/coerceInputValue.js.map +7 -0
  101. package/lib/utilities/coerceInputValue.mjs +167 -0
  102. package/lib/utilities/coerceInputValue.mjs.map +7 -0
  103. package/lib/utilities/decodeASTSchema.d.ts +7 -0
  104. package/lib/utilities/decodeASTSchema.d.ts.map +1 -0
  105. package/lib/utilities/decodeASTSchema.js +246 -0
  106. package/lib/utilities/decodeASTSchema.js.map +7 -0
  107. package/lib/utilities/decodeASTSchema.mjs +245 -0
  108. package/lib/utilities/decodeASTSchema.mjs.map +7 -0
  109. package/lib/utilities/encodeASTSchema.d.ts +4 -0
  110. package/lib/utilities/encodeASTSchema.d.ts.map +1 -0
  111. package/lib/utilities/encodeASTSchema.js +151 -0
  112. package/lib/utilities/encodeASTSchema.js.map +7 -0
  113. package/lib/utilities/encodeASTSchema.mjs +134 -0
  114. package/lib/utilities/encodeASTSchema.mjs.map +7 -0
  115. package/lib/utilities/extractMinimalViableSchemaForRequestDocument.d.ts +8 -0
  116. package/lib/utilities/extractMinimalViableSchemaForRequestDocument.d.ts.map +1 -0
  117. package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js +238 -0
  118. package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js.map +7 -0
  119. package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs +245 -0
  120. package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs.map +7 -0
  121. package/lib/utilities/makeReadableErrorPath.d.ts +3 -0
  122. package/lib/utilities/makeReadableErrorPath.d.ts.map +1 -0
  123. package/lib/utilities/makeReadableErrorPath.js +47 -0
  124. package/lib/utilities/makeReadableErrorPath.js.map +7 -0
  125. package/lib/utilities/makeReadableErrorPath.mjs +28 -0
  126. package/lib/utilities/makeReadableErrorPath.mjs.map +7 -0
  127. package/lib/utilities/mergeResolvers.d.ts +2 -2
  128. package/lib/utilities/mergeResolvers.d.ts.map +1 -1
  129. package/lib/utilities/mergeResolvers.js +20 -22
  130. package/lib/utilities/mergeResolvers.js.map +2 -2
  131. package/lib/utilities/mergeResolvers.mjs +20 -25
  132. package/lib/utilities/mergeResolvers.mjs.map +2 -2
  133. package/lib/utilities/mergeSchemaDefinitions.d.ts +8 -0
  134. package/lib/utilities/mergeSchemaDefinitions.d.ts.map +1 -0
  135. package/lib/utilities/mergeSchemaDefinitions.js +126 -0
  136. package/lib/utilities/mergeSchemaDefinitions.js.map +7 -0
  137. package/lib/utilities/mergeSchemaDefinitions.mjs +114 -0
  138. package/lib/utilities/mergeSchemaDefinitions.mjs.map +7 -0
  139. package/lib/utilities/typeNameFromAST.d.ts +1 -1
  140. package/lib/utilities/typeNameFromAST.d.ts.map +1 -1
  141. package/lib/utilities/typeNameFromAST.js.map +2 -2
  142. package/lib/utilities/typeNameFromAST.mjs.map +2 -2
  143. package/lib/utilities/valueFromAST.d.ts +27 -0
  144. package/lib/utilities/valueFromAST.d.ts.map +1 -0
  145. package/lib/utilities/valueFromAST.js +139 -0
  146. package/lib/utilities/valueFromAST.js.map +7 -0
  147. package/lib/utilities/valueFromAST.mjs +125 -0
  148. package/lib/utilities/valueFromAST.mjs.map +7 -0
  149. package/lib/utilities/valueFromASTUntyped.d.ts +21 -0
  150. package/lib/utilities/valueFromASTUntyped.d.ts.map +1 -0
  151. package/lib/utilities/valueFromASTUntyped.js +51 -0
  152. package/lib/utilities/valueFromASTUntyped.js.map +7 -0
  153. package/lib/utilities/valueFromASTUntyped.mjs +32 -0
  154. package/lib/utilities/valueFromASTUntyped.mjs.map +7 -0
  155. package/lib/values.d.ts +8 -12
  156. package/lib/values.d.ts.map +1 -1
  157. package/lib/values.js +75 -63
  158. package/lib/values.js.map +2 -2
  159. package/lib/values.mjs +77 -71
  160. package/lib/values.mjs.map +2 -2
  161. package/package.json +8 -6
  162. package/lib/definition.d.ts +0 -7
  163. package/lib/definition.d.ts.map +0 -1
  164. package/lib/definition.js +0 -59
  165. package/lib/definition.js.map +0 -7
  166. package/lib/definition.mjs +0 -40
  167. package/lib/definition.mjs.map +0 -7
  168. package/lib/directives.d.ts +0 -8
  169. package/lib/directives.d.ts.map +0 -1
  170. package/lib/directives.js +0 -47
  171. package/lib/directives.js.map +0 -7
  172. package/lib/directives.mjs +0 -37
  173. package/lib/directives.mjs.map +0 -7
  174. package/lib/extractImplicitTypesRuntime.d.ts +0 -4
  175. package/lib/extractImplicitTypesRuntime.d.ts.map +0 -1
  176. package/lib/extractImplicitTypesRuntime.js +0 -123
  177. package/lib/extractImplicitTypesRuntime.js.map +0 -7
  178. package/lib/extractImplicitTypesRuntime.mjs +0 -114
  179. package/lib/extractImplicitTypesRuntime.mjs.map +0 -7
  180. package/lib/supermassive-ast/TypedAST.d.ts +0 -370
  181. package/lib/supermassive-ast/TypedAST.d.ts.map +0 -1
  182. package/lib/supermassive-ast/TypedAST.js.map +0 -7
  183. package/lib/supermassive-ast/TypedAST.mjs +0 -10
  184. package/lib/supermassive-ast/TypedAST.mjs.map +0 -7
  185. package/lib/supermassive-ast/addTypesToRequestDocument.d.ts +0 -56
  186. package/lib/supermassive-ast/addTypesToRequestDocument.d.ts.map +0 -1
  187. package/lib/supermassive-ast/addTypesToRequestDocument.js +0 -473
  188. package/lib/supermassive-ast/addTypesToRequestDocument.js.map +0 -7
  189. package/lib/supermassive-ast/addTypesToRequestDocument.mjs +0 -463
  190. package/lib/supermassive-ast/addTypesToRequestDocument.mjs.map +0 -7
  191. package/lib/supermassive-ast/annotateDocumentGraphQLTransform.d.ts +0 -3
  192. package/lib/supermassive-ast/annotateDocumentGraphQLTransform.d.ts.map +0 -1
  193. package/lib/supermassive-ast/annotateDocumentGraphQLTransform.js.map +0 -7
  194. package/lib/supermassive-ast/annotateDocumentGraphQLTransform.mjs +0 -17
  195. package/lib/supermassive-ast/annotateDocumentGraphQLTransform.mjs.map +0 -7
  196. package/lib/supermassive-ast/directives.d.ts +0 -36
  197. package/lib/supermassive-ast/directives.d.ts.map +0 -1
  198. package/lib/supermassive-ast/directives.js +0 -165
  199. package/lib/supermassive-ast/directives.js.map +0 -7
  200. package/lib/supermassive-ast/directives.mjs +0 -153
  201. package/lib/supermassive-ast/directives.mjs.map +0 -7
  202. package/lib/supermassive-ast/index.d.ts +0 -6
  203. package/lib/supermassive-ast/index.d.ts.map +0 -1
  204. package/lib/supermassive-ast/index.js +0 -37
  205. package/lib/supermassive-ast/index.js.map +0 -7
  206. package/lib/supermassive-ast/index.mjs +0 -27
  207. package/lib/supermassive-ast/index.mjs.map +0 -7
package/lib/values.js CHANGED
@@ -20,19 +20,21 @@ var values_exports = {};
20
20
  __export(values_exports, {
21
21
  getArgumentValues: () => getArgumentValues,
22
22
  getDirectiveValues: () => getDirectiveValues,
23
- getVariableValues: () => getVariableValues,
24
- specifiedScalars: () => specifiedScalars
23
+ getVariableValues: () => getVariableValues
25
24
  });
26
25
  module.exports = __toCommonJS(values_exports);
27
26
  var import_graphql = require("graphql");
28
27
  var import_inspect = require("./jsutils/inspect");
29
28
  var import_printPathArray = require("./jsutils/printPathArray");
30
- function getVariableValues(resolvers, varDefNodes, inputs, options) {
29
+ var import_valueFromAST = require("./utilities/valueFromAST");
30
+ var import_coerceInputValue = require("./utilities/coerceInputValue");
31
+ var import_reference = require("./schema/reference");
32
+ function getVariableValues(schemaTypes, varDefNodes, inputs, options) {
31
33
  const errors = [];
32
34
  const maxErrors = options == null ? void 0 : options.maxErrors;
33
35
  try {
34
36
  const coerced = coerceVariableValues(
35
- resolvers,
37
+ schemaTypes,
36
38
  varDefNodes,
37
39
  inputs,
38
40
  (error) => {
@@ -52,14 +54,13 @@ function getVariableValues(resolvers, varDefNodes, inputs, options) {
52
54
  }
53
55
  return { errors };
54
56
  }
55
- function coerceVariableValues(resolvers, varDefNodes, inputs, onError) {
57
+ function coerceVariableValues(schemaTypes, varDefNodes, inputs, onError) {
56
58
  const coercedValues = {};
57
59
  for (const varDefNode of varDefNodes) {
58
60
  const varName = varDefNode.variable.name.value;
59
- const varTypeAst = varDefNode.type;
60
- const varType = graphqlTypeFromTypeAst(resolvers, varTypeAst);
61
- if (!(0, import_graphql.isInputType)(varType)) {
62
- const varTypeStr = (0, import_inspect.inspect)(varType);
61
+ const varTypeReference = (0, import_reference.typeReferenceFromNode)(varDefNode.type);
62
+ if (!schemaTypes.isInputType(varTypeReference)) {
63
+ const varTypeStr = (0, import_reference.inspectTypeReference)(varTypeReference);
63
64
  onError(
64
65
  new import_graphql.GraphQLError(
65
66
  `Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`,
@@ -70,12 +71,13 @@ function coerceVariableValues(resolvers, varDefNodes, inputs, onError) {
70
71
  }
71
72
  if (!hasOwnProperty(inputs, varName)) {
72
73
  if (varDefNode.defaultValue) {
73
- coercedValues[varName] = (0, import_graphql.valueFromAST)(
74
+ coercedValues[varName] = (0, import_valueFromAST.valueFromAST)(
74
75
  varDefNode.defaultValue,
75
- varType
76
+ varTypeReference,
77
+ schemaTypes
76
78
  );
77
- } else if ((0, import_graphql.isNonNullType)(varType)) {
78
- const varTypeStr = (0, import_graphql.print)(varDefNode.type);
79
+ } else if ((0, import_reference.isNonNullType)(varTypeReference)) {
80
+ const varTypeStr = (0, import_reference.inspectTypeReference)(varTypeReference);
79
81
  onError(
80
82
  new import_graphql.GraphQLError(
81
83
  `Variable "$${varName}" of required type "${varTypeStr}" was not provided.`,
@@ -86,8 +88,8 @@ function coerceVariableValues(resolvers, varDefNodes, inputs, onError) {
86
88
  continue;
87
89
  }
88
90
  const value = inputs[varName];
89
- if (value === null && (0, import_graphql.isNonNullType)(varType)) {
90
- const varTypeStr = (0, import_inspect.inspect)(varType);
91
+ if (value === null && (0, import_reference.isNonNullType)(varTypeReference)) {
92
+ const varTypeStr = (0, import_reference.inspectTypeReference)(varTypeReference);
91
93
  onError(
92
94
  new import_graphql.GraphQLError(
93
95
  `Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`,
@@ -96,9 +98,10 @@ function coerceVariableValues(resolvers, varDefNodes, inputs, onError) {
96
98
  );
97
99
  continue;
98
100
  }
99
- coercedValues[varName] = (0, import_graphql.coerceInputValue)(
101
+ coercedValues[varName] = (0, import_coerceInputValue.coerceInputValue)(
100
102
  value,
101
- varType,
103
+ varTypeReference,
104
+ schemaTypes,
102
105
  (path, invalidValue, error) => {
103
106
  let prefix = `Variable "$${varName}" got invalid value ` + (0, import_inspect.inspect)(invalidValue);
104
107
  if (path.length > 0) {
@@ -115,47 +118,72 @@ function coerceVariableValues(resolvers, varDefNodes, inputs, onError) {
115
118
  }
116
119
  return coercedValues;
117
120
  }
118
- function getArgumentValues(resolvers, node, variableValues) {
121
+ function getArgumentValues(exeContext, def, node) {
119
122
  var _a;
123
+ const schemaTypes = exeContext.partialSchema;
120
124
  const coercedValues = {};
125
+ const argumentDefs = schemaTypes.resolveDefinitionArguments(def);
126
+ if (!argumentDefs) {
127
+ return coercedValues;
128
+ }
121
129
  const argumentNodes = (_a = node.arguments) != null ? _a : [];
122
- for (const argumentNode of argumentNodes) {
123
- const name = argumentNode.name.value;
124
- const argTypeNode = argumentNode.__type;
125
- const argType = graphqlTypeFromTypeAst(resolvers, argTypeNode);
126
- if (!(0, import_graphql.isInputType)(argType)) {
127
- throw new import_graphql.GraphQLError(
128
- `Argument "$${name}" expected value of type "${(0, import_inspect.inspect)(
129
- argType
130
- )}" which cannot be used as an input type.`,
131
- { nodes: argumentNode }
130
+ const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg]));
131
+ for (const [name, argumentDef] of Object.entries(argumentDefs)) {
132
+ const argumentNode = argNodeMap.get(name);
133
+ const argumentTypeRef = schemaTypes.getTypeReference(argumentDef);
134
+ const defaultValue = schemaTypes.getInputDefaultValue(argumentDef);
135
+ if (argumentNode == null) {
136
+ if (defaultValue !== void 0) {
137
+ coercedValues[name] = defaultValue;
138
+ } else if ((0, import_reference.isNonNullType)(argumentTypeRef)) {
139
+ const type = (0, import_reference.inspectTypeReference)(argumentTypeRef);
140
+ throw (0, import_graphql.locatedError)(
141
+ `Argument "${name}" of required type "${type}" was not provided.`,
142
+ [node]
143
+ );
144
+ }
145
+ continue;
146
+ }
147
+ if (!schemaTypes.isDefined(argumentTypeRef)) {
148
+ throw (0, import_graphql.locatedError)(
149
+ `Could not find type for argument ${name} in ${node.kind} ${node.name.value}`,
150
+ [argumentNode]
132
151
  );
133
152
  }
134
- let valueNode = argumentNode.value;
153
+ const valueNode = argumentNode.value;
154
+ let isNull = valueNode.kind === import_graphql.Kind.NULL;
135
155
  if (valueNode.kind === import_graphql.Kind.VARIABLE) {
136
156
  const variableName = valueNode.name.value;
137
- if (variableValues == null || !hasOwnProperty(variableValues, variableName)) {
138
- if (argumentNode.__defaultValue) {
139
- valueNode = argumentNode.__defaultValue;
140
- } else if ((0, import_graphql.isNonNullType)(argType)) {
141
- throw new import_graphql.GraphQLError(
142
- `Argument "${name}" of required type "${(0, import_inspect.inspect)(argType)}" was provided the variable "$${variableName}" which was not provided a runtime value.`,
143
- { nodes: valueNode }
157
+ if (exeContext.variableValues == null || !hasOwnProperty(exeContext.variableValues, variableName)) {
158
+ if (defaultValue !== void 0) {
159
+ coercedValues[name] = defaultValue;
160
+ } else if ((0, import_reference.isNonNullType)(argumentTypeRef)) {
161
+ const type = (0, import_reference.inspectTypeReference)(argumentTypeRef);
162
+ throw (0, import_graphql.locatedError)(
163
+ `Argument "${name}" of required type "${type}" was provided the variable "$${variableName}" which was not provided a runtime value.`,
164
+ [valueNode]
144
165
  );
145
166
  }
146
167
  continue;
147
168
  }
169
+ isNull = exeContext.variableValues[variableName] == null;
170
+ }
171
+ if (isNull && (0, import_reference.isNonNullType)(argumentTypeRef)) {
172
+ const type = (0, import_reference.inspectTypeReference)(argumentTypeRef);
173
+ throw (0, import_graphql.locatedError)(
174
+ `Argument "${name}" of non-null type "${type}" must not be null."`,
175
+ [valueNode]
176
+ );
148
177
  }
149
- const coercedValue = (0, import_graphql.valueFromAST)(
178
+ const coercedValue = (0, import_valueFromAST.valueFromAST)(
150
179
  valueNode,
151
- argType,
152
- variableValues
180
+ argumentTypeRef,
181
+ schemaTypes,
182
+ exeContext.variableValues
153
183
  );
154
184
  if (coercedValue === void 0) {
155
185
  throw new import_graphql.GraphQLError(
156
- `Argument "${name}" has invalid value ${(0, import_graphql.print)(
157
- valueNode
158
- )}.`,
186
+ `Argument "${name}" has invalid value ${(0, import_graphql.print)(valueNode)}.`,
159
187
  { nodes: valueNode }
160
188
  );
161
189
  }
@@ -163,33 +191,17 @@ function getArgumentValues(resolvers, node, variableValues) {
163
191
  }
164
192
  return coercedValues;
165
193
  }
166
- function getDirectiveValues(directiveDef, node, resolvers, variableValues) {
194
+ function getDirectiveValues(exeContext, directiveDef, node) {
167
195
  var _a;
196
+ const schemaTypes = exeContext.partialSchema;
197
+ const name = schemaTypes.getDirectiveName(directiveDef);
168
198
  const directiveNode = (_a = node.directives) == null ? void 0 : _a.find(
169
- (directive) => directive.name.value === directiveDef.name
199
+ (directive) => directive.name.value === name
170
200
  );
171
201
  if (directiveNode) {
172
- return getArgumentValues(resolvers, directiveNode, variableValues);
202
+ return getArgumentValues(exeContext, directiveDef, directiveNode);
173
203
  }
174
204
  }
175
205
  function hasOwnProperty(obj, prop) {
176
206
  return Object.prototype.hasOwnProperty.call(obj, prop);
177
207
  }
178
- const specifiedScalars = {
179
- ID: import_graphql.GraphQLID,
180
- String: import_graphql.GraphQLString,
181
- Int: import_graphql.GraphQLInt,
182
- Float: import_graphql.GraphQLFloat,
183
- Boolean: import_graphql.GraphQLBoolean
184
- };
185
- function graphqlTypeFromTypeAst(resolvers, node) {
186
- if (node.kind === import_graphql.Kind.NON_NULL_TYPE) {
187
- return new import_graphql.GraphQLNonNull(graphqlTypeFromTypeAst(resolvers, node.type));
188
- } else if (node.kind === import_graphql.Kind.LIST_TYPE) {
189
- return new import_graphql.GraphQLList(graphqlTypeFromTypeAst(resolvers, node.type));
190
- } else {
191
- const typeName = node.name.value;
192
- const type = specifiedScalars[typeName] || resolvers[typeName];
193
- return type;
194
- }
195
- }
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 ArgumentNode as GraphQLArgumentNode,\n GraphQLBoolean,\n GraphQLError,\n GraphQLFloat,\n GraphQLID,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLScalarType,\n GraphQLString,\n GraphQLType,\n isInputType,\n isNonNullType,\n Kind,\n print,\n TypeNode as GraphQLTypeNode,\n ValueNode as GraphQLValueNode,\n VariableDefinitionNode as GraphQLVariableDefinitionNode,\n valueFromAST,\n coerceInputValue,\n GraphQLDirective,\n} from \"graphql\";\nimport {\n DirectiveNode,\n FieldNode,\n TypeNode,\n VariableDefinitionNode,\n} from \"./supermassive-ast\";\nimport { inspect } from \"./jsutils/inspect\";\nimport type { Maybe } from \"./jsutils/Maybe\";\nimport type { ObjMap } from \"./jsutils/ObjMap\";\nimport { printPathArray } from \"./jsutils/printPathArray\";\nimport { Resolvers } 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 resolvers: Resolvers,\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 resolvers,\n varDefNodes,\n inputs,\n (error) => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw new GraphQLError(\n \"Too many errors processing variables, error limit reached. Execution aborted.\",\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 resolvers: Resolvers,\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 varTypeAst = varDefNode.type;\n const varType: GraphQLType = graphqlTypeFromTypeAst(resolvers, varTypeAst);\n\n if (!isInputType(varType)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n const varTypeStr = inspect(varType);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`,\n { nodes: varDefNode.type as GraphQLTypeNode },\n ),\n );\n continue;\n }\n\n if (!hasOwnProperty(inputs, varName)) {\n if (varDefNode.defaultValue) {\n coercedValues[varName] = valueFromAST(\n varDefNode.defaultValue as Maybe<GraphQLValueNode>,\n varType,\n );\n } else if (isNonNullType(varType)) {\n const varTypeStr = print(varDefNode.type as GraphQLTypeNode);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of required type \"${varTypeStr}\" was not provided.`,\n { nodes: varDefNode as GraphQLVariableDefinitionNode },\n ),\n );\n }\n continue;\n }\n\n const value = inputs[varName];\n if (value === null && isNonNullType(varType)) {\n const varTypeStr = inspect(varType);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of non-null type \"${varTypeStr}\" must not be null.`,\n { nodes: varDefNode as GraphQLVariableDefinitionNode },\n ),\n );\n continue;\n }\n\n coercedValues[varName] = coerceInputValue(\n value,\n varType,\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(\n new GraphQLError(prefix + \"; \" + error.message, {\n nodes: varDefNode as GraphQLVariableDefinitionNode,\n originalError: error.originalError,\n }),\n );\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 resolvers: Resolvers,\n node: FieldNode | DirectiveNode,\n variableValues?: Maybe<ObjMap<unknown>>,\n): { [argument: string]: unknown } {\n const coercedValues: { [argument: string]: unknown } = {};\n\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argumentNodes = node.arguments ?? [];\n\n for (const argumentNode of argumentNodes) {\n const name = argumentNode.name.value;\n const argTypeNode = argumentNode.__type;\n const argType = graphqlTypeFromTypeAst(resolvers, argTypeNode);\n\n if (!isInputType(argType)) {\n throw new GraphQLError(\n `Argument \"$${name}\" expected value of type \"${inspect(\n argType,\n )}\" which cannot be used as an input type.`,\n { nodes: argumentNode as GraphQLArgumentNode },\n );\n }\n\n let valueNode = argumentNode.value;\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n if (\n variableValues == null ||\n !hasOwnProperty(variableValues, variableName)\n ) {\n if (argumentNode.__defaultValue) {\n valueNode = argumentNode.__defaultValue;\n } else if (isNonNullType(argType)) {\n throw new GraphQLError(\n `Argument \"${name}\" of required type \"${inspect(argType)}\" ` +\n `was provided the variable \"$${variableName}\" which was not provided a runtime value.`,\n { nodes: valueNode as GraphQLValueNode },\n );\n }\n\n continue;\n }\n }\n\n const coercedValue = valueFromAST(\n valueNode as GraphQLValueNode,\n argType,\n 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 new GraphQLError(\n `Argument \"${name}\" has invalid value ${print(\n valueNode as GraphQLValueNode,\n )}.`,\n { nodes: valueNode as GraphQLValueNode },\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 directiveDef: GraphQLDirective,\n node: { directives?: ReadonlyArray<DirectiveNode> },\n resolvers: Resolvers,\n variableValues?: Maybe<ObjMap<unknown>>,\n): undefined | { [argument: string]: unknown } {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const directiveNode = node.directives?.find(\n (directive) => directive.name.value === directiveDef.name,\n );\n\n if (directiveNode) {\n return getArgumentValues(resolvers, directiveNode, variableValues);\n }\n}\n\nfunction hasOwnProperty(obj: unknown, prop: string): boolean {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport const specifiedScalars: { [key: string]: GraphQLScalarType } = {\n ID: GraphQLID,\n String: GraphQLString,\n Int: GraphQLInt,\n Float: GraphQLFloat,\n Boolean: GraphQLBoolean,\n};\n\nfunction graphqlTypeFromTypeAst(\n resolvers: Resolvers,\n node: TypeNode,\n): GraphQLType {\n if (node.kind === Kind.NON_NULL_TYPE) {\n return new GraphQLNonNull(graphqlTypeFromTypeAst(resolvers, node.type));\n } else if (node.kind === Kind.LIST_TYPE) {\n return new GraphQLList(graphqlTypeFromTypeAst(resolvers, node.type));\n } else {\n const typeName = node.name.value;\n const type = specifiedScalars[typeName] || resolvers[typeName];\n return type as GraphQLType;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAsBO;AAOP,qBAAwB;AAGxB,4BAA+B;AAkBxB,SAAS,kBACd,WACA,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,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AACA,eAAO,KAAK,KAAK;AAAA,MACnB;AAAA,IACF;AAEA,QAAI,OAAO,WAAW,GAAG;AACvB,aAAO,EAAE,QAAQ;AAAA,IACnB;AAAA,EACF,SAAS,OAAP;AACA,WAAO,KAAK,KAAqB;AAAA,EACnC;AAEA,SAAO,EAAE,OAAe;AAC1B;AAEA,SAAS,qBACP,WACA,aACA,QACA,SACiC;AACjC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AAU,KAAK,UAAU,aAAa;AAAA;AAGvD,MAAI,eAAe;AACjB,WAAO,kBAAkB,WAAW,eAAe,cAAc;AAAA,EACnE;AACF;AAEA,SAAS,eAAe,KAAc,MAAuB;AAC3D,SAAO,OAAO,UAAU,eAAe,KAAK,KAAK,IAAI;AACvD;AAEO,MAAM,mBAAyD;AAAA,EACpE,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AACX;AAEA,SAAS,uBACP,WACA,MACa;AACb,MAAI,KAAK,SAAS,oBAAK,eAAe;AACpC,WAAO,IAAI,8BAAe,uBAAuB,WAAW,KAAK,IAAI,CAAC;AAAA,EACxE,WAAW,KAAK,SAAS,oBAAK,WAAW;AACvC,WAAO,IAAI,2BAAY,uBAAuB,WAAW,KAAK,IAAI,CAAC;AAAA,EACrE,OAAO;AACL,UAAM,WAAW,KAAK,KAAK;AAC3B,UAAM,OAAO,iBAAiB,QAAQ,KAAK,UAAU,QAAQ;AAC7D,WAAO;AAAA,EACT;AACF;",
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 { DirectiveDefinitionTuple, FieldDefinition } from \"./schema/definition\";\nimport { valueFromAST } from \"./utilities/valueFromAST\";\nimport { PartialSchema } from \"./schema/fragment\";\nimport { coerceInputValue } from \"./utilities/coerceInputValue\";\nimport {\n inspectTypeReference,\n isNonNullType,\n typeReferenceFromNode,\n} from \"./schema/reference\";\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 schemaTypes: PartialSchema,\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 schemaTypes,\n varDefNodes,\n inputs,\n (error) => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw new GraphQLError(\n \"Too many errors processing variables, error limit reached. Execution aborted.\",\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 schemaTypes: PartialSchema,\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 (!schemaTypes.isInputType(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 new GraphQLError(\n `Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`,\n { nodes: 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 schemaTypes,\n );\n } else if (isNonNullType(varTypeReference)) {\n const varTypeStr = inspectTypeReference(varTypeReference);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of required type \"${varTypeStr}\" was not provided.`,\n { nodes: 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 new GraphQLError(\n `Variable \"$${varName}\" of non-null type \"${varTypeStr}\" must not be null.`,\n { nodes: varDefNode },\n ),\n );\n continue;\n }\n\n coercedValues[varName] = coerceInputValue(\n value,\n varTypeReference,\n schemaTypes,\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(\n new GraphQLError(prefix + \"; \" + error.message, {\n nodes: varDefNode,\n originalError: error.originalError,\n }),\n );\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 schemaTypes = exeContext.partialSchema;\n const coercedValues: { [argument: string]: unknown } = {};\n const argumentDefs = schemaTypes.resolveDefinitionArguments(def);\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 = schemaTypes.getTypeReference(argumentDef);\n const defaultValue = schemaTypes.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 (!schemaTypes.isDefined(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 schemaTypes,\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 new GraphQLError(\n `Argument \"${name}\" has invalid value ${print(valueNode)}.`,\n { nodes: 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 schemaTypes = exeContext.partialSchema;\n const name = schemaTypes.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;AAG/B,0BAA6B;AAE7B,8BAAiC;AACjC,uBAIO;AAiBA,SAAS,kBACd,aACA,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,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AACA,eAAO,KAAK,KAAK;AAAA,MACnB;AAAA,IACF;AAEA,QAAI,OAAO,WAAW,GAAG;AACvB,aAAO,EAAE,QAAQ;AAAA,IACnB;AAAA,EACF,SAAS,OAAP;AACA,WAAO,KAAK,KAAqB;AAAA,EACnC;AAEA,SAAO,EAAE,OAAe;AAC1B;AAEA,SAAS,qBACP,aACA,aACA,QACA,SACiC;AACjC,QAAM,gBAAiD,CAAC;AACxD,aAAW,cAAc,aAAa;AACpC,UAAM,UAAU,WAAW,SAAS,KAAK;AACzC,UAAM,uBAAmB,wCAAs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2BAA2B,qCACP;AAAA,YACjC,CAAC,SAAS;AAAA,UACZ;AAAA,QACF;AACA;AAAA,MACF;AACA,eAAS,WAAW,eAAe,YAAY,KAAK;AAAA,IACtD;AAEA,QAAI,cAAU,gCAAc,eAAe,GAAG;AAC5C,YAAM,WAAO,uCAAqB,eAAe;AACjD,gBAAM;AAAA,QACJ,aAAa,2BAA2B;AAAA,QACxC,CAAC,SAAS;AAAA,MACZ;AAAA,IACF;AAEA,UAAM,mBAAe;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,IACb;AACA,QAAI,iBAAiB,QAAW;AAI9B,YAAM,IAAI;AAAA,QACR,aAAa,+BAA2B,sBAAM,SAAS;AAAA,QACvD,EAAE,OAAO,UAAU;AAAA,MACrB;AAAA,IACF;AACA,kBAAc,IAAI,IAAI;AAAA,EACxB;AAEA,SAAO;AACT;AAaO,SAAS,mBACd,YACA,cACA,MAC6C;AAlR/C;AAmRE,QAAM,cAAc,WAAW;AAC/B,QAAM,OAAO,YAAY,iBAAiB,YAAY;AAGtD,QAAM,iBAAgB,UAAK,eAAL,mBAAiB;AAAA,IACrC,CAAC,cAAc,UAAU,KAAK,UAAU;AAAA;AAG1C,MAAI,eAAe;AACjB,WAAO,kBAAkB,YAAY,cAAc,aAAa;AAAA,EAClE;AACF;AAEA,SAAS,eAAe,KAAc,MAAuB;AAC3D,SAAO,OAAO,UAAU,eAAe,KAAK,KAAK,IAAI;AACvD;",
6
6
  "names": []
7
7
  }
package/lib/values.mjs CHANGED
@@ -1,28 +1,25 @@
1
1
  // src/values.ts
2
2
  import {
3
- GraphQLBoolean,
4
3
  GraphQLError,
5
- GraphQLFloat,
6
- GraphQLID,
7
- GraphQLInt,
8
- GraphQLList,
9
- GraphQLNonNull,
10
- GraphQLString,
11
- isInputType,
12
- isNonNullType,
13
4
  Kind,
14
5
  print,
15
- valueFromAST,
16
- coerceInputValue
6
+ locatedError
17
7
  } from "graphql";
18
8
  import { inspect } from "./jsutils/inspect.mjs";
19
9
  import { printPathArray } from "./jsutils/printPathArray.mjs";
20
- function getVariableValues(resolvers, varDefNodes, inputs, options) {
10
+ import { valueFromAST } from "./utilities/valueFromAST.mjs";
11
+ import { coerceInputValue } from "./utilities/coerceInputValue.mjs";
12
+ import {
13
+ inspectTypeReference,
14
+ isNonNullType,
15
+ typeReferenceFromNode
16
+ } from "./schema/reference.mjs";
17
+ function getVariableValues(schemaTypes, varDefNodes, inputs, options) {
21
18
  const errors = [];
22
19
  const maxErrors = options == null ? void 0 : options.maxErrors;
23
20
  try {
24
21
  const coerced = coerceVariableValues(
25
- resolvers,
22
+ schemaTypes,
26
23
  varDefNodes,
27
24
  inputs,
28
25
  (error) => {
@@ -42,14 +39,13 @@ function getVariableValues(resolvers, varDefNodes, inputs, options) {
42
39
  }
43
40
  return { errors };
44
41
  }
45
- function coerceVariableValues(resolvers, varDefNodes, inputs, onError) {
42
+ function coerceVariableValues(schemaTypes, varDefNodes, inputs, onError) {
46
43
  const coercedValues = {};
47
44
  for (const varDefNode of varDefNodes) {
48
45
  const varName = varDefNode.variable.name.value;
49
- const varTypeAst = varDefNode.type;
50
- const varType = graphqlTypeFromTypeAst(resolvers, varTypeAst);
51
- if (!isInputType(varType)) {
52
- const varTypeStr = inspect(varType);
46
+ const varTypeReference = typeReferenceFromNode(varDefNode.type);
47
+ if (!schemaTypes.isInputType(varTypeReference)) {
48
+ const varTypeStr = inspectTypeReference(varTypeReference);
53
49
  onError(
54
50
  new GraphQLError(
55
51
  `Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`,
@@ -62,10 +58,11 @@ function coerceVariableValues(resolvers, varDefNodes, inputs, onError) {
62
58
  if (varDefNode.defaultValue) {
63
59
  coercedValues[varName] = valueFromAST(
64
60
  varDefNode.defaultValue,
65
- varType
61
+ varTypeReference,
62
+ schemaTypes
66
63
  );
67
- } else if (isNonNullType(varType)) {
68
- const varTypeStr = print(varDefNode.type);
64
+ } else if (isNonNullType(varTypeReference)) {
65
+ const varTypeStr = inspectTypeReference(varTypeReference);
69
66
  onError(
70
67
  new GraphQLError(
71
68
  `Variable "$${varName}" of required type "${varTypeStr}" was not provided.`,
@@ -76,8 +73,8 @@ function coerceVariableValues(resolvers, varDefNodes, inputs, onError) {
76
73
  continue;
77
74
  }
78
75
  const value = inputs[varName];
79
- if (value === null && isNonNullType(varType)) {
80
- const varTypeStr = inspect(varType);
76
+ if (value === null && isNonNullType(varTypeReference)) {
77
+ const varTypeStr = inspectTypeReference(varTypeReference);
81
78
  onError(
82
79
  new GraphQLError(
83
80
  `Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`,
@@ -88,7 +85,8 @@ function coerceVariableValues(resolvers, varDefNodes, inputs, onError) {
88
85
  }
89
86
  coercedValues[varName] = coerceInputValue(
90
87
  value,
91
- varType,
88
+ varTypeReference,
89
+ schemaTypes,
92
90
  (path, invalidValue, error) => {
93
91
  let prefix = `Variable "$${varName}" got invalid value ` + inspect(invalidValue);
94
92
  if (path.length > 0) {
@@ -105,47 +103,72 @@ function coerceVariableValues(resolvers, varDefNodes, inputs, onError) {
105
103
  }
106
104
  return coercedValues;
107
105
  }
108
- function getArgumentValues(resolvers, node, variableValues) {
106
+ function getArgumentValues(exeContext, def, node) {
109
107
  var _a;
108
+ const schemaTypes = exeContext.partialSchema;
110
109
  const coercedValues = {};
110
+ const argumentDefs = schemaTypes.resolveDefinitionArguments(def);
111
+ if (!argumentDefs) {
112
+ return coercedValues;
113
+ }
111
114
  const argumentNodes = (_a = node.arguments) != null ? _a : [];
112
- for (const argumentNode of argumentNodes) {
113
- const name = argumentNode.name.value;
114
- const argTypeNode = argumentNode.__type;
115
- const argType = graphqlTypeFromTypeAst(resolvers, argTypeNode);
116
- if (!isInputType(argType)) {
117
- throw new GraphQLError(
118
- `Argument "$${name}" expected value of type "${inspect(
119
- argType
120
- )}" which cannot be used as an input type.`,
121
- { nodes: argumentNode }
115
+ const argNodeMap = new Map(argumentNodes.map((arg) => [arg.name.value, arg]));
116
+ for (const [name, argumentDef] of Object.entries(argumentDefs)) {
117
+ const argumentNode = argNodeMap.get(name);
118
+ const argumentTypeRef = schemaTypes.getTypeReference(argumentDef);
119
+ const defaultValue = schemaTypes.getInputDefaultValue(argumentDef);
120
+ if (argumentNode == null) {
121
+ if (defaultValue !== void 0) {
122
+ coercedValues[name] = defaultValue;
123
+ } else if (isNonNullType(argumentTypeRef)) {
124
+ const type = inspectTypeReference(argumentTypeRef);
125
+ throw locatedError(
126
+ `Argument "${name}" of required type "${type}" was not provided.`,
127
+ [node]
128
+ );
129
+ }
130
+ continue;
131
+ }
132
+ if (!schemaTypes.isDefined(argumentTypeRef)) {
133
+ throw locatedError(
134
+ `Could not find type for argument ${name} in ${node.kind} ${node.name.value}`,
135
+ [argumentNode]
122
136
  );
123
137
  }
124
- let valueNode = argumentNode.value;
138
+ const valueNode = argumentNode.value;
139
+ let isNull = valueNode.kind === Kind.NULL;
125
140
  if (valueNode.kind === Kind.VARIABLE) {
126
141
  const variableName = valueNode.name.value;
127
- if (variableValues == null || !hasOwnProperty(variableValues, variableName)) {
128
- if (argumentNode.__defaultValue) {
129
- valueNode = argumentNode.__defaultValue;
130
- } else if (isNonNullType(argType)) {
131
- throw new GraphQLError(
132
- `Argument "${name}" of required type "${inspect(argType)}" was provided the variable "$${variableName}" which was not provided a runtime value.`,
133
- { nodes: valueNode }
142
+ if (exeContext.variableValues == null || !hasOwnProperty(exeContext.variableValues, variableName)) {
143
+ if (defaultValue !== void 0) {
144
+ coercedValues[name] = defaultValue;
145
+ } else if (isNonNullType(argumentTypeRef)) {
146
+ const type = inspectTypeReference(argumentTypeRef);
147
+ throw locatedError(
148
+ `Argument "${name}" of required type "${type}" was provided the variable "$${variableName}" which was not provided a runtime value.`,
149
+ [valueNode]
134
150
  );
135
151
  }
136
152
  continue;
137
153
  }
154
+ isNull = exeContext.variableValues[variableName] == null;
155
+ }
156
+ if (isNull && isNonNullType(argumentTypeRef)) {
157
+ const type = inspectTypeReference(argumentTypeRef);
158
+ throw locatedError(
159
+ `Argument "${name}" of non-null type "${type}" must not be null."`,
160
+ [valueNode]
161
+ );
138
162
  }
139
163
  const coercedValue = valueFromAST(
140
164
  valueNode,
141
- argType,
142
- variableValues
165
+ argumentTypeRef,
166
+ schemaTypes,
167
+ exeContext.variableValues
143
168
  );
144
169
  if (coercedValue === void 0) {
145
170
  throw new GraphQLError(
146
- `Argument "${name}" has invalid value ${print(
147
- valueNode
148
- )}.`,
171
+ `Argument "${name}" has invalid value ${print(valueNode)}.`,
149
172
  { nodes: valueNode }
150
173
  );
151
174
  }
@@ -153,39 +176,22 @@ function getArgumentValues(resolvers, node, variableValues) {
153
176
  }
154
177
  return coercedValues;
155
178
  }
156
- function getDirectiveValues(directiveDef, node, resolvers, variableValues) {
179
+ function getDirectiveValues(exeContext, directiveDef, node) {
157
180
  var _a;
181
+ const schemaTypes = exeContext.partialSchema;
182
+ const name = schemaTypes.getDirectiveName(directiveDef);
158
183
  const directiveNode = (_a = node.directives) == null ? void 0 : _a.find(
159
- (directive) => directive.name.value === directiveDef.name
184
+ (directive) => directive.name.value === name
160
185
  );
161
186
  if (directiveNode) {
162
- return getArgumentValues(resolvers, directiveNode, variableValues);
187
+ return getArgumentValues(exeContext, directiveDef, directiveNode);
163
188
  }
164
189
  }
165
190
  function hasOwnProperty(obj, prop) {
166
191
  return Object.prototype.hasOwnProperty.call(obj, prop);
167
192
  }
168
- var specifiedScalars = {
169
- ID: GraphQLID,
170
- String: GraphQLString,
171
- Int: GraphQLInt,
172
- Float: GraphQLFloat,
173
- Boolean: GraphQLBoolean
174
- };
175
- function graphqlTypeFromTypeAst(resolvers, node) {
176
- if (node.kind === Kind.NON_NULL_TYPE) {
177
- return new GraphQLNonNull(graphqlTypeFromTypeAst(resolvers, node.type));
178
- } else if (node.kind === Kind.LIST_TYPE) {
179
- return new GraphQLList(graphqlTypeFromTypeAst(resolvers, node.type));
180
- } else {
181
- const typeName = node.name.value;
182
- const type = specifiedScalars[typeName] || resolvers[typeName];
183
- return type;
184
- }
185
- }
186
193
  export {
187
194
  getArgumentValues,
188
195
  getDirectiveValues,
189
- getVariableValues,
190
- specifiedScalars
196
+ getVariableValues
191
197
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/values.ts"],
4
- "sourcesContent": ["import {\n ArgumentNode as GraphQLArgumentNode,\n GraphQLBoolean,\n GraphQLError,\n GraphQLFloat,\n GraphQLID,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLScalarType,\n GraphQLString,\n GraphQLType,\n isInputType,\n isNonNullType,\n Kind,\n print,\n TypeNode as GraphQLTypeNode,\n ValueNode as GraphQLValueNode,\n VariableDefinitionNode as GraphQLVariableDefinitionNode,\n valueFromAST,\n coerceInputValue,\n GraphQLDirective,\n} from \"graphql\";\nimport {\n DirectiveNode,\n FieldNode,\n TypeNode,\n VariableDefinitionNode,\n} from \"./supermassive-ast\";\nimport { inspect } from \"./jsutils/inspect\";\nimport type { Maybe } from \"./jsutils/Maybe\";\nimport type { ObjMap } from \"./jsutils/ObjMap\";\nimport { printPathArray } from \"./jsutils/printPathArray\";\nimport { Resolvers } 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 resolvers: Resolvers,\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 resolvers,\n varDefNodes,\n inputs,\n (error) => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw new GraphQLError(\n \"Too many errors processing variables, error limit reached. Execution aborted.\",\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 resolvers: Resolvers,\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 varTypeAst = varDefNode.type;\n const varType: GraphQLType = graphqlTypeFromTypeAst(resolvers, varTypeAst);\n\n if (!isInputType(varType)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n const varTypeStr = inspect(varType);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`,\n { nodes: varDefNode.type as GraphQLTypeNode },\n ),\n );\n continue;\n }\n\n if (!hasOwnProperty(inputs, varName)) {\n if (varDefNode.defaultValue) {\n coercedValues[varName] = valueFromAST(\n varDefNode.defaultValue as Maybe<GraphQLValueNode>,\n varType,\n );\n } else if (isNonNullType(varType)) {\n const varTypeStr = print(varDefNode.type as GraphQLTypeNode);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of required type \"${varTypeStr}\" was not provided.`,\n { nodes: varDefNode as GraphQLVariableDefinitionNode },\n ),\n );\n }\n continue;\n }\n\n const value = inputs[varName];\n if (value === null && isNonNullType(varType)) {\n const varTypeStr = inspect(varType);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of non-null type \"${varTypeStr}\" must not be null.`,\n { nodes: varDefNode as GraphQLVariableDefinitionNode },\n ),\n );\n continue;\n }\n\n coercedValues[varName] = coerceInputValue(\n value,\n varType,\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(\n new GraphQLError(prefix + \"; \" + error.message, {\n nodes: varDefNode as GraphQLVariableDefinitionNode,\n originalError: error.originalError,\n }),\n );\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 resolvers: Resolvers,\n node: FieldNode | DirectiveNode,\n variableValues?: Maybe<ObjMap<unknown>>,\n): { [argument: string]: unknown } {\n const coercedValues: { [argument: string]: unknown } = {};\n\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argumentNodes = node.arguments ?? [];\n\n for (const argumentNode of argumentNodes) {\n const name = argumentNode.name.value;\n const argTypeNode = argumentNode.__type;\n const argType = graphqlTypeFromTypeAst(resolvers, argTypeNode);\n\n if (!isInputType(argType)) {\n throw new GraphQLError(\n `Argument \"$${name}\" expected value of type \"${inspect(\n argType,\n )}\" which cannot be used as an input type.`,\n { nodes: argumentNode as GraphQLArgumentNode },\n );\n }\n\n let valueNode = argumentNode.value;\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n if (\n variableValues == null ||\n !hasOwnProperty(variableValues, variableName)\n ) {\n if (argumentNode.__defaultValue) {\n valueNode = argumentNode.__defaultValue;\n } else if (isNonNullType(argType)) {\n throw new GraphQLError(\n `Argument \"${name}\" of required type \"${inspect(argType)}\" ` +\n `was provided the variable \"$${variableName}\" which was not provided a runtime value.`,\n { nodes: valueNode as GraphQLValueNode },\n );\n }\n\n continue;\n }\n }\n\n const coercedValue = valueFromAST(\n valueNode as GraphQLValueNode,\n argType,\n 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 new GraphQLError(\n `Argument \"${name}\" has invalid value ${print(\n valueNode as GraphQLValueNode,\n )}.`,\n { nodes: valueNode as GraphQLValueNode },\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 directiveDef: GraphQLDirective,\n node: { directives?: ReadonlyArray<DirectiveNode> },\n resolvers: Resolvers,\n variableValues?: Maybe<ObjMap<unknown>>,\n): undefined | { [argument: string]: unknown } {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const directiveNode = node.directives?.find(\n (directive) => directive.name.value === directiveDef.name,\n );\n\n if (directiveNode) {\n return getArgumentValues(resolvers, directiveNode, variableValues);\n }\n}\n\nfunction hasOwnProperty(obj: unknown, prop: string): boolean {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport const specifiedScalars: { [key: string]: GraphQLScalarType } = {\n ID: GraphQLID,\n String: GraphQLString,\n Int: GraphQLInt,\n Float: GraphQLFloat,\n Boolean: GraphQLBoolean,\n};\n\nfunction graphqlTypeFromTypeAst(\n resolvers: Resolvers,\n node: TypeNode,\n): GraphQLType {\n if (node.kind === Kind.NON_NULL_TYPE) {\n return new GraphQLNonNull(graphqlTypeFromTypeAst(resolvers, node.type));\n } else if (node.kind === Kind.LIST_TYPE) {\n return new GraphQLList(graphqlTypeFromTypeAst(resolvers, node.type));\n } else {\n const typeName = node.name.value;\n const type = specifiedScalars[typeName] || resolvers[typeName];\n return type as GraphQLType;\n }\n}\n"],
5
- "mappings": ";AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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K,UAAU,QAAQ;AAC7D,WAAO;AAAA,EACT;AACF;",
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 { DirectiveDefinitionTuple, FieldDefinition } from \"./schema/definition\";\nimport { valueFromAST } from \"./utilities/valueFromAST\";\nimport { PartialSchema } from \"./schema/fragment\";\nimport { coerceInputValue } from \"./utilities/coerceInputValue\";\nimport {\n inspectTypeReference,\n isNonNullType,\n typeReferenceFromNode,\n} from \"./schema/reference\";\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 schemaTypes: PartialSchema,\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 schemaTypes,\n varDefNodes,\n inputs,\n (error) => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw new GraphQLError(\n \"Too many errors processing variables, error limit reached. Execution aborted.\",\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 schemaTypes: PartialSchema,\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 (!schemaTypes.isInputType(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 new GraphQLError(\n `Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`,\n { nodes: 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 schemaTypes,\n );\n } else if (isNonNullType(varTypeReference)) {\n const varTypeStr = inspectTypeReference(varTypeReference);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of required type \"${varTypeStr}\" was not provided.`,\n { nodes: 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 new GraphQLError(\n `Variable \"$${varName}\" of non-null type \"${varTypeStr}\" must not be null.`,\n { nodes: varDefNode },\n ),\n );\n continue;\n }\n\n coercedValues[varName] = coerceInputValue(\n value,\n varTypeReference,\n schemaTypes,\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(\n new GraphQLError(prefix + \"; \" + error.message, {\n nodes: varDefNode,\n originalError: error.originalError,\n }),\n );\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 schemaTypes = exeContext.partialSchema;\n const coercedValues: { [argument: string]: unknown } = {};\n const argumentDefs = schemaTypes.resolveDefinitionArguments(def);\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 = schemaTypes.getTypeReference(argumentDef);\n const defaultValue = schemaTypes.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 (!schemaTypes.isDefined(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 schemaTypes,\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 new GraphQLError(\n `Argument \"${name}\" has invalid value ${print(valueNode)}.`,\n { nodes: 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 schemaTypes = exeContext.partialSchema;\n const name = schemaTypes.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,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAG/B,SAAS,oBAAoB;AAE7B,SAAS,wBAAwB;AACjC;AAA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