@graphitation/supermassive 2.2.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintcache +1 -1
- package/lib/ast/TypedAST.js +1 -0
- package/lib/ast/addTypesToRequestDocument.js +48 -42
- package/lib/ast/addTypesToRequestDocument.mjs +47 -42
- package/lib/benchmarks/index.js +15 -4
- package/lib/benchmarks/index.mjs +6 -3
- package/lib/benchmarks/nice-benchmark.js +1 -0
- package/lib/benchmarks/swapi-schema/index.js +14 -4
- package/lib/benchmarks/swapi-schema/index.mjs +5 -3
- package/lib/benchmarks/swapi-schema/models.js +9 -1
- package/lib/benchmarks/swapi-schema/resolvers.js +22 -7
- package/lib/benchmarks/swapi-schema/resolvers.mjs +21 -7
- package/lib/collectFields.js +41 -11
- package/lib/collectFields.mjs +40 -11
- package/lib/compiledQuery.js +1 -0
- package/lib/definition.js +13 -8
- package/lib/definition.mjs +12 -8
- package/lib/directives.js +48 -33
- package/lib/directives.mjs +47 -33
- package/lib/executeWithSchema.js +1 -0
- package/lib/executeWithoutSchema.js +231 -49
- package/lib/executeWithoutSchema.mjs +224 -46
- package/lib/extractImplicitTypesRuntime.js +4 -1
- package/lib/extractImplicitTypesRuntime.mjs +3 -1
- package/lib/index.js +1 -0
- package/lib/jsutils/Maybe.js +1 -0
- package/lib/jsutils/ObjMap.js +1 -0
- package/lib/jsutils/Path.js +1 -0
- package/lib/jsutils/PromiseOrValue.js +1 -0
- package/lib/jsutils/devAssert.js +1 -0
- package/lib/jsutils/didYouMean.js +1 -0
- package/lib/jsutils/identityFunc.js +1 -0
- package/lib/jsutils/inspect.js +4 -1
- package/lib/jsutils/inspect.mjs +3 -1
- package/lib/jsutils/instanceOf.js +18 -6
- package/lib/jsutils/instanceOf.mjs +17 -6
- package/lib/jsutils/invariant.js +4 -1
- package/lib/jsutils/invariant.mjs +3 -1
- package/lib/jsutils/isAsyncIterable.js +1 -0
- package/lib/jsutils/isIterableObject.js +1 -0
- package/lib/jsutils/isObjectLike.js +1 -0
- package/lib/jsutils/isPromise.js +1 -0
- package/lib/jsutils/keyMap.js +1 -0
- package/lib/jsutils/keyValMap.js +1 -0
- package/lib/jsutils/mapValue.js +1 -0
- package/lib/jsutils/memoize3.js +1 -0
- package/lib/jsutils/naturalCompare.js +1 -0
- package/lib/jsutils/printPathArray.js +4 -1
- package/lib/jsutils/printPathArray.mjs +3 -1
- package/lib/jsutils/promiseForObject.js +1 -0
- package/lib/jsutils/promiseReduce.js +1 -0
- package/lib/jsutils/suggestionList.js +9 -1
- package/lib/jsutils/suggestionList.mjs +8 -1
- package/lib/jsutils/toObjMap.js +1 -0
- package/lib/subscribeWithSchema.js +1 -0
- package/lib/subscribeWithoutSchema.js +45 -6
- package/lib/subscribeWithoutSchema.mjs +44 -6
- package/lib/transforms/annotateDocumentGraphQLTransform.js +1 -0
- package/lib/types.js +1 -0
- package/lib/utilities/blankGraphQLTag.js +1 -0
- package/lib/utilities/mapAsyncIterator.js +1 -0
- package/lib/utilities/mergeResolvers.js +1 -0
- package/lib/utilities/typeNameFromAST.js +1 -0
- package/lib/values.js +82 -21
- package/lib/values.mjs +81 -21
- package/package.json +1 -1
package/lib/values.mjs
CHANGED
|
@@ -22,12 +22,19 @@ function getVariableValues(resolvers, varDefNodes, inputs, options) {
|
|
|
22
22
|
const errors = [];
|
|
23
23
|
const maxErrors = options == null ? void 0 : options.maxErrors;
|
|
24
24
|
try {
|
|
25
|
-
const coerced = coerceVariableValues(
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const coerced = coerceVariableValues(
|
|
26
|
+
resolvers,
|
|
27
|
+
varDefNodes,
|
|
28
|
+
inputs,
|
|
29
|
+
(error) => {
|
|
30
|
+
if (maxErrors != null && errors.length >= maxErrors) {
|
|
31
|
+
throw new GraphQLError(
|
|
32
|
+
"Too many errors processing variables, error limit reached. Execution aborted."
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
errors.push(error);
|
|
28
36
|
}
|
|
29
|
-
|
|
30
|
-
});
|
|
37
|
+
);
|
|
31
38
|
if (errors.length === 0) {
|
|
32
39
|
return { coerced };
|
|
33
40
|
}
|
|
@@ -44,31 +51,62 @@ function coerceVariableValues(resolvers, varDefNodes, inputs, onError) {
|
|
|
44
51
|
const varType = graphqlTypeFromTypeAst(resolvers, varTypeAst);
|
|
45
52
|
if (!isInputType(varType)) {
|
|
46
53
|
const varTypeStr = inspect(varType);
|
|
47
|
-
onError(
|
|
54
|
+
onError(
|
|
55
|
+
new GraphQLError(
|
|
56
|
+
`Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`,
|
|
57
|
+
varDefNode.type
|
|
58
|
+
)
|
|
59
|
+
);
|
|
48
60
|
continue;
|
|
49
61
|
}
|
|
50
62
|
if (!hasOwnProperty(inputs, varName)) {
|
|
51
63
|
if (varDefNode.defaultValue) {
|
|
52
|
-
coercedValues[varName] = valueFromAST(
|
|
64
|
+
coercedValues[varName] = valueFromAST(
|
|
65
|
+
varDefNode.defaultValue,
|
|
66
|
+
varType
|
|
67
|
+
);
|
|
53
68
|
} else if (isNonNullType(varType)) {
|
|
54
69
|
const varTypeStr = print(varDefNode.type);
|
|
55
|
-
onError(
|
|
70
|
+
onError(
|
|
71
|
+
new GraphQLError(
|
|
72
|
+
`Variable "$${varName}" of required type "${varTypeStr}" was not provided.`,
|
|
73
|
+
varDefNode
|
|
74
|
+
)
|
|
75
|
+
);
|
|
56
76
|
}
|
|
57
77
|
continue;
|
|
58
78
|
}
|
|
59
79
|
const value = inputs[varName];
|
|
60
80
|
if (value === null && isNonNullType(varType)) {
|
|
61
81
|
const varTypeStr = inspect(varType);
|
|
62
|
-
onError(
|
|
82
|
+
onError(
|
|
83
|
+
new GraphQLError(
|
|
84
|
+
`Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`,
|
|
85
|
+
varDefNode
|
|
86
|
+
)
|
|
87
|
+
);
|
|
63
88
|
continue;
|
|
64
89
|
}
|
|
65
|
-
coercedValues[varName] = coerceInputValue(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
90
|
+
coercedValues[varName] = coerceInputValue(
|
|
91
|
+
value,
|
|
92
|
+
varType,
|
|
93
|
+
(path, invalidValue, error) => {
|
|
94
|
+
let prefix = `Variable "$${varName}" got invalid value ` + inspect(invalidValue);
|
|
95
|
+
if (path.length > 0) {
|
|
96
|
+
prefix += ` at "${varName}${printPathArray(path)}"`;
|
|
97
|
+
}
|
|
98
|
+
onError(
|
|
99
|
+
new GraphQLError(
|
|
100
|
+
prefix + "; " + error.message,
|
|
101
|
+
varDefNode,
|
|
102
|
+
void 0,
|
|
103
|
+
void 0,
|
|
104
|
+
void 0,
|
|
105
|
+
error.originalError
|
|
106
|
+
)
|
|
107
|
+
);
|
|
69
108
|
}
|
|
70
|
-
|
|
71
|
-
});
|
|
109
|
+
);
|
|
72
110
|
}
|
|
73
111
|
return coercedValues;
|
|
74
112
|
}
|
|
@@ -76,14 +114,22 @@ function getArgumentValues(resolvers, node, variableValues) {
|
|
|
76
114
|
var _a;
|
|
77
115
|
const coercedValues = {};
|
|
78
116
|
const argumentNodes = (_a = node.arguments) != null ? _a : [];
|
|
79
|
-
const argNodeMap = keyMap(
|
|
117
|
+
const argNodeMap = keyMap(
|
|
118
|
+
argumentNodes,
|
|
119
|
+
(arg) => arg.name.value
|
|
120
|
+
);
|
|
80
121
|
for (const argumentNode of argumentNodes) {
|
|
81
122
|
const name = argumentNode.name.value;
|
|
82
123
|
const argTypeNode = argumentNode.__type;
|
|
83
124
|
const argType = graphqlTypeFromTypeAst(resolvers, argTypeNode);
|
|
84
125
|
if (!isInputType(argType)) {
|
|
85
126
|
console.log(argType, isInputType(argType));
|
|
86
|
-
throw new GraphQLError(
|
|
127
|
+
throw new GraphQLError(
|
|
128
|
+
`Argument "$${name}" expected value of type "${inspect(
|
|
129
|
+
argType
|
|
130
|
+
)}" which cannot be used as an input type.`,
|
|
131
|
+
argumentNode
|
|
132
|
+
);
|
|
87
133
|
}
|
|
88
134
|
let valueNode = argumentNode.value;
|
|
89
135
|
let isNull = valueNode.kind === Kind.NULL;
|
|
@@ -93,15 +139,27 @@ function getArgumentValues(resolvers, node, variableValues) {
|
|
|
93
139
|
if (argumentNode.__defaultValue != void 0) {
|
|
94
140
|
valueNode = argumentNode.__defaultValue;
|
|
95
141
|
} else if (isNonNullType(argType)) {
|
|
96
|
-
throw new GraphQLError(
|
|
142
|
+
throw new GraphQLError(
|
|
143
|
+
`Argument "${name}" of required type "${inspect(argType)}" was provided the variable "$${variableName}" which was not provided a runtime value.`,
|
|
144
|
+
valueNode
|
|
145
|
+
);
|
|
97
146
|
}
|
|
98
147
|
continue;
|
|
99
148
|
}
|
|
100
149
|
isNull = !variableValues || variableValues[variableName] == null;
|
|
101
150
|
}
|
|
102
|
-
const coercedValue = valueFromAST(
|
|
151
|
+
const coercedValue = valueFromAST(
|
|
152
|
+
valueNode,
|
|
153
|
+
argType,
|
|
154
|
+
variableValues
|
|
155
|
+
);
|
|
103
156
|
if (coercedValue === void 0) {
|
|
104
|
-
throw new GraphQLError(
|
|
157
|
+
throw new GraphQLError(
|
|
158
|
+
`Argument "${name}" has invalid value ${print(
|
|
159
|
+
valueNode
|
|
160
|
+
)}.`,
|
|
161
|
+
valueNode
|
|
162
|
+
);
|
|
105
163
|
}
|
|
106
164
|
coercedValues[name] = coercedValue;
|
|
107
165
|
}
|
|
@@ -109,7 +167,9 @@ function getArgumentValues(resolvers, node, variableValues) {
|
|
|
109
167
|
}
|
|
110
168
|
function getDirectiveValues(directiveDef, node, resolvers, variableValues) {
|
|
111
169
|
var _a;
|
|
112
|
-
const directiveNode = (_a = node.directives) == null ? void 0 : _a.find(
|
|
170
|
+
const directiveNode = (_a = node.directives) == null ? void 0 : _a.find(
|
|
171
|
+
(directive) => directive.name.value === directiveDef.name
|
|
172
|
+
);
|
|
113
173
|
if (directiveNode) {
|
|
114
174
|
return getArgumentValues(resolvers, directiveNode, variableValues);
|
|
115
175
|
}
|