@graphitation/supermassive 3.0.0-alpha.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintcache +1 -1
- package/CHANGELOG.md +22 -2
- package/README.md +11 -2
- package/lib/__testUtils__/execute.d.ts +1 -1
- package/lib/__testUtils__/execute.d.ts.map +1 -1
- package/lib/__testUtils__/execute.js +1 -1
- package/lib/__testUtils__/execute.js.map +2 -2
- package/lib/__testUtils__/execute.mjs +1 -2
- package/lib/__testUtils__/execute.mjs.map +2 -2
- package/lib/benchmarks/swapi-schema/resolvers.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/resolvers.js.map +2 -2
- package/lib/benchmarks/swapi-schema/resolvers.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +26 -22
- package/lib/executeWithoutSchema.js.map +2 -2
- package/lib/executeWithoutSchema.mjs +26 -23
- package/lib/executeWithoutSchema.mjs.map +2 -2
- package/lib/utilities/coerceInputValue.d.ts.map +1 -1
- package/lib/utilities/coerceInputValue.js +17 -12
- package/lib/utilities/coerceInputValue.js.map +2 -2
- package/lib/utilities/coerceInputValue.mjs +18 -13
- package/lib/utilities/coerceInputValue.mjs.map +2 -2
- package/lib/utilities/decodeASTSchema.js.map +2 -2
- package/lib/utilities/decodeASTSchema.mjs.map +2 -2
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.d.ts.map +1 -1
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js +3 -7
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js.map +2 -2
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs +5 -9
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs.map +2 -2
- package/lib/values.d.ts.map +1 -1
- package/lib/values.js +12 -16
- package/lib/values.js.map +2 -2
- package/lib/values.mjs +12 -17
- package/lib/values.mjs.map +2 -2
- package/package.json +4 -5
- package/scripts/install-graphql-17.js +41 -0
package/lib/values.js
CHANGED
|
@@ -40,8 +40,9 @@ function getVariableValues(schemaFragment, varDefNodes, inputs, options) {
|
|
|
40
40
|
inputs,
|
|
41
41
|
(error) => {
|
|
42
42
|
if (maxErrors != null && errors.length >= maxErrors) {
|
|
43
|
-
throw
|
|
44
|
-
"Too many errors processing variables, error limit reached. Execution aborted."
|
|
43
|
+
throw (0, import_graphql.locatedError)(
|
|
44
|
+
"Too many errors processing variables, error limit reached. Execution aborted.",
|
|
45
|
+
[]
|
|
45
46
|
);
|
|
46
47
|
}
|
|
47
48
|
errors.push(error);
|
|
@@ -63,9 +64,9 @@ function coerceVariableValues(schemaFragment, varDefNodes, inputs, onError) {
|
|
|
63
64
|
if (!(0, import_definition.isInputType)(schemaFragment.definitions, varTypeReference)) {
|
|
64
65
|
const varTypeStr = (0, import_reference.inspectTypeReference)(varTypeReference);
|
|
65
66
|
onError(
|
|
66
|
-
|
|
67
|
+
(0, import_graphql.locatedError)(
|
|
67
68
|
`Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`,
|
|
68
|
-
|
|
69
|
+
[varDefNode.type]
|
|
69
70
|
)
|
|
70
71
|
);
|
|
71
72
|
continue;
|
|
@@ -80,9 +81,9 @@ function coerceVariableValues(schemaFragment, varDefNodes, inputs, onError) {
|
|
|
80
81
|
} else if ((0, import_reference.isNonNullType)(varTypeReference)) {
|
|
81
82
|
const varTypeStr = (0, import_reference.inspectTypeReference)(varTypeReference);
|
|
82
83
|
onError(
|
|
83
|
-
|
|
84
|
+
(0, import_graphql.locatedError)(
|
|
84
85
|
`Variable "$${varName}" of required type "${varTypeStr}" was not provided.`,
|
|
85
|
-
|
|
86
|
+
[varDefNode]
|
|
86
87
|
)
|
|
87
88
|
);
|
|
88
89
|
}
|
|
@@ -92,9 +93,9 @@ function coerceVariableValues(schemaFragment, varDefNodes, inputs, onError) {
|
|
|
92
93
|
if (value === null && (0, import_reference.isNonNullType)(varTypeReference)) {
|
|
93
94
|
const varTypeStr = (0, import_reference.inspectTypeReference)(varTypeReference);
|
|
94
95
|
onError(
|
|
95
|
-
|
|
96
|
+
(0, import_graphql.locatedError)(
|
|
96
97
|
`Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`,
|
|
97
|
-
|
|
98
|
+
[varDefNode]
|
|
98
99
|
)
|
|
99
100
|
);
|
|
100
101
|
continue;
|
|
@@ -108,12 +109,7 @@ function coerceVariableValues(schemaFragment, varDefNodes, inputs, onError) {
|
|
|
108
109
|
if (path.length > 0) {
|
|
109
110
|
prefix += ` at "${varName}${(0, import_printPathArray.printPathArray)(path)}"`;
|
|
110
111
|
}
|
|
111
|
-
onError(
|
|
112
|
-
new import_graphql.GraphQLError(prefix + "; " + error.message, {
|
|
113
|
-
nodes: varDefNode,
|
|
114
|
-
originalError: error.originalError
|
|
115
|
-
})
|
|
116
|
-
);
|
|
112
|
+
onError((0, import_graphql.locatedError)(prefix + "; " + error.message, [varDefNode]));
|
|
117
113
|
}
|
|
118
114
|
);
|
|
119
115
|
}
|
|
@@ -183,9 +179,9 @@ function getArgumentValues(exeContext, def, node) {
|
|
|
183
179
|
exeContext.variableValues
|
|
184
180
|
);
|
|
185
181
|
if (coercedValue === void 0) {
|
|
186
|
-
throw
|
|
182
|
+
throw (0, import_graphql.locatedError)(
|
|
187
183
|
`Argument "${name}" has invalid value ${(0, import_graphql.print)(valueNode)}.`,
|
|
188
|
-
|
|
184
|
+
[valueNode]
|
|
189
185
|
);
|
|
190
186
|
}
|
|
191
187
|
coercedValues[name] = coercedValue;
|
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 getDefinitionArguments,\n getDirectiveName,\n getInputDefaultValue,\n getInputValueTypeReference,\n isDefined,\n isInputType,\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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAQO;AACP,qBAAwB;AACxB,4BAA+B;AAE/B,wBASO;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,
|
|
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 getDefinitionArguments,\n getDirectiveName,\n getInputDefaultValue,\n getInputValueTypeReference,\n isDefined,\n isInputType,\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 = getDefinitionArguments(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 = 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,wBASO;AACP,0BAA6B;AAC7B,8BAAiC;AACjC,uBAIO;AAkBA,SAAS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K,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,6 +1,5 @@
|
|
|
1
1
|
// src/values.ts
|
|
2
2
|
import {
|
|
3
|
-
GraphQLError,
|
|
4
3
|
Kind,
|
|
5
4
|
print,
|
|
6
5
|
locatedError
|
|
@@ -32,8 +31,9 @@ function getVariableValues(schemaFragment, varDefNodes, inputs, options) {
|
|
|
32
31
|
inputs,
|
|
33
32
|
(error) => {
|
|
34
33
|
if (maxErrors != null && errors.length >= maxErrors) {
|
|
35
|
-
throw
|
|
36
|
-
"Too many errors processing variables, error limit reached. Execution aborted."
|
|
34
|
+
throw locatedError(
|
|
35
|
+
"Too many errors processing variables, error limit reached. Execution aborted.",
|
|
36
|
+
[]
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
errors.push(error);
|
|
@@ -55,9 +55,9 @@ function coerceVariableValues(schemaFragment, varDefNodes, inputs, onError) {
|
|
|
55
55
|
if (!isInputType(schemaFragment.definitions, varTypeReference)) {
|
|
56
56
|
const varTypeStr = inspectTypeReference(varTypeReference);
|
|
57
57
|
onError(
|
|
58
|
-
|
|
58
|
+
locatedError(
|
|
59
59
|
`Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`,
|
|
60
|
-
|
|
60
|
+
[varDefNode.type]
|
|
61
61
|
)
|
|
62
62
|
);
|
|
63
63
|
continue;
|
|
@@ -72,9 +72,9 @@ function coerceVariableValues(schemaFragment, varDefNodes, inputs, onError) {
|
|
|
72
72
|
} else if (isNonNullType(varTypeReference)) {
|
|
73
73
|
const varTypeStr = inspectTypeReference(varTypeReference);
|
|
74
74
|
onError(
|
|
75
|
-
|
|
75
|
+
locatedError(
|
|
76
76
|
`Variable "$${varName}" of required type "${varTypeStr}" was not provided.`,
|
|
77
|
-
|
|
77
|
+
[varDefNode]
|
|
78
78
|
)
|
|
79
79
|
);
|
|
80
80
|
}
|
|
@@ -84,9 +84,9 @@ function coerceVariableValues(schemaFragment, varDefNodes, inputs, onError) {
|
|
|
84
84
|
if (value === null && isNonNullType(varTypeReference)) {
|
|
85
85
|
const varTypeStr = inspectTypeReference(varTypeReference);
|
|
86
86
|
onError(
|
|
87
|
-
|
|
87
|
+
locatedError(
|
|
88
88
|
`Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`,
|
|
89
|
-
|
|
89
|
+
[varDefNode]
|
|
90
90
|
)
|
|
91
91
|
);
|
|
92
92
|
continue;
|
|
@@ -100,12 +100,7 @@ function coerceVariableValues(schemaFragment, varDefNodes, inputs, onError) {
|
|
|
100
100
|
if (path.length > 0) {
|
|
101
101
|
prefix += ` at "${varName}${printPathArray(path)}"`;
|
|
102
102
|
}
|
|
103
|
-
onError(
|
|
104
|
-
new GraphQLError(prefix + "; " + error.message, {
|
|
105
|
-
nodes: varDefNode,
|
|
106
|
-
originalError: error.originalError
|
|
107
|
-
})
|
|
108
|
-
);
|
|
103
|
+
onError(locatedError(prefix + "; " + error.message, [varDefNode]));
|
|
109
104
|
}
|
|
110
105
|
);
|
|
111
106
|
}
|
|
@@ -175,9 +170,9 @@ function getArgumentValues(exeContext, def, node) {
|
|
|
175
170
|
exeContext.variableValues
|
|
176
171
|
);
|
|
177
172
|
if (coercedValue === void 0) {
|
|
178
|
-
throw
|
|
173
|
+
throw locatedError(
|
|
179
174
|
`Argument "${name}" has invalid value ${print(valueNode)}.`,
|
|
180
|
-
|
|
175
|
+
[valueNode]
|
|
181
176
|
);
|
|
182
177
|
}
|
|
183
178
|
coercedValues[name] = coercedValue;
|
package/lib/values.mjs.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 getDefinitionArguments,\n getDirectiveName,\n getInputDefaultValue,\n getInputValueTypeReference,\n isDefined,\n isInputType,\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
|
|
5
|
-
"mappings": ";AAAA;AAAA,
|
|
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 getDefinitionArguments,\n getDirectiveName,\n getInputDefaultValue,\n getInputValueTypeReference,\n isDefined,\n isInputType,\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 = getDefinitionArguments(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 = 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,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAE/B;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAkBA,SAAS,kBACd,gBACA,aACA,QACA,SACuB;AACvB,QAAM,SAAyB,CAAC;AAChC,QAAM,YAAY,mCAAS;AAC3B,MAAI;AACF,UAAM,UAAU;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O,UAAU,eAAe,KAAK,KAAK,IAAI;AACvD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphitation/supermassive",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "3.0.0
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"main": "./lib/index",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -14,18 +14,17 @@
|
|
|
14
14
|
"test": "monorepo-scripts test",
|
|
15
15
|
"types": "monorepo-scripts types",
|
|
16
16
|
"just": "monorepo-scripts",
|
|
17
|
-
"
|
|
17
|
+
"graphql17": "node ./scripts/install-graphql-17.js",
|
|
18
|
+
"test17": "yarn graphql17 && yarn jest --config=../../scripts/config/jest.config.js --testMatch='**/*.graphql17.test.ts' --testPathIgnorePatterns='node_modules' --diagnostics=false",
|
|
18
19
|
"benchmark": "ts-node -T ./src/benchmarks/index.ts"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
|
-
"@graphitation/supermassive-extractors": "*",
|
|
22
22
|
"@graphitation/cli": "*",
|
|
23
23
|
"@ts-morph/bootstrap": "^0.11.0",
|
|
24
24
|
"@types/benchmark": "^2.1.0",
|
|
25
25
|
"@types/jest": "^26.0.22",
|
|
26
26
|
"@types/node-json-db": "^0.9.3",
|
|
27
27
|
"benchmark": "^2.1.4",
|
|
28
|
-
"graphql": "17.0.0-alpha.2",
|
|
29
28
|
"graphql-jit": "^0.8.4",
|
|
30
29
|
"iterall": "^1.3.0",
|
|
31
30
|
"monorepo-scripts": "*",
|
|
@@ -38,7 +37,7 @@
|
|
|
38
37
|
"publishConfig": {},
|
|
39
38
|
"dependencies": {},
|
|
40
39
|
"peerDependencies": {
|
|
41
|
-
"graphql": "^17.0.0"
|
|
40
|
+
"graphql": "^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
42
41
|
},
|
|
43
42
|
"types": "./lib/index.d.ts",
|
|
44
43
|
"module": "./lib/index.mjs",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// Supermassive V3 requires graphql17 for defer/stream tests, and graphql15 for other tests
|
|
3
|
+
// By default graphql15 is installed, this scripts installs graphql17 for local testing of defer/stream
|
|
4
|
+
const fs = require("fs").promises;
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const util = require("util");
|
|
7
|
+
const exec = util.promisify(require("child_process").exec);
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
if (isInstalled()) return;
|
|
11
|
+
|
|
12
|
+
const packageJsonPath = path.join(__dirname, "..", "package.json");
|
|
13
|
+
const packageJsonData = await fs.readFile(packageJsonPath, "utf-8");
|
|
14
|
+
|
|
15
|
+
const { stderr } = await exec(
|
|
16
|
+
`yarn add graphql@17.0.0-alpha.2 --exact --dev --no-lockfile`,
|
|
17
|
+
);
|
|
18
|
+
console.log(stderr);
|
|
19
|
+
|
|
20
|
+
// Yarn modifies package.json, and we don't want that
|
|
21
|
+
// Workaround for missing yarn feature: https://github.com/yarnpkg/yarn/issues/1743
|
|
22
|
+
await fs.writeFile(packageJsonPath, packageJsonData, "utf-8");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isInstalled() {
|
|
26
|
+
const packageJsonPath = path.join(
|
|
27
|
+
__dirname,
|
|
28
|
+
"..",
|
|
29
|
+
"node_modules",
|
|
30
|
+
"graphql",
|
|
31
|
+
"package.json",
|
|
32
|
+
);
|
|
33
|
+
try {
|
|
34
|
+
const packageJsonData = require(packageJsonPath);
|
|
35
|
+
return packageJsonData.version.startsWith("17.");
|
|
36
|
+
} catch (e) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
main().catch(console.error);
|