@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.
Files changed (66) hide show
  1. package/.eslintcache +1 -1
  2. package/lib/ast/TypedAST.js +1 -0
  3. package/lib/ast/addTypesToRequestDocument.js +48 -42
  4. package/lib/ast/addTypesToRequestDocument.mjs +47 -42
  5. package/lib/benchmarks/index.js +15 -4
  6. package/lib/benchmarks/index.mjs +6 -3
  7. package/lib/benchmarks/nice-benchmark.js +1 -0
  8. package/lib/benchmarks/swapi-schema/index.js +14 -4
  9. package/lib/benchmarks/swapi-schema/index.mjs +5 -3
  10. package/lib/benchmarks/swapi-schema/models.js +9 -1
  11. package/lib/benchmarks/swapi-schema/resolvers.js +22 -7
  12. package/lib/benchmarks/swapi-schema/resolvers.mjs +21 -7
  13. package/lib/collectFields.js +41 -11
  14. package/lib/collectFields.mjs +40 -11
  15. package/lib/compiledQuery.js +1 -0
  16. package/lib/definition.js +13 -8
  17. package/lib/definition.mjs +12 -8
  18. package/lib/directives.js +48 -33
  19. package/lib/directives.mjs +47 -33
  20. package/lib/executeWithSchema.js +1 -0
  21. package/lib/executeWithoutSchema.js +231 -49
  22. package/lib/executeWithoutSchema.mjs +224 -46
  23. package/lib/extractImplicitTypesRuntime.js +4 -1
  24. package/lib/extractImplicitTypesRuntime.mjs +3 -1
  25. package/lib/index.js +1 -0
  26. package/lib/jsutils/Maybe.js +1 -0
  27. package/lib/jsutils/ObjMap.js +1 -0
  28. package/lib/jsutils/Path.js +1 -0
  29. package/lib/jsutils/PromiseOrValue.js +1 -0
  30. package/lib/jsutils/devAssert.js +1 -0
  31. package/lib/jsutils/didYouMean.js +1 -0
  32. package/lib/jsutils/identityFunc.js +1 -0
  33. package/lib/jsutils/inspect.js +4 -1
  34. package/lib/jsutils/inspect.mjs +3 -1
  35. package/lib/jsutils/instanceOf.js +18 -6
  36. package/lib/jsutils/instanceOf.mjs +17 -6
  37. package/lib/jsutils/invariant.js +4 -1
  38. package/lib/jsutils/invariant.mjs +3 -1
  39. package/lib/jsutils/isAsyncIterable.js +1 -0
  40. package/lib/jsutils/isIterableObject.js +1 -0
  41. package/lib/jsutils/isObjectLike.js +1 -0
  42. package/lib/jsutils/isPromise.js +1 -0
  43. package/lib/jsutils/keyMap.js +1 -0
  44. package/lib/jsutils/keyValMap.js +1 -0
  45. package/lib/jsutils/mapValue.js +1 -0
  46. package/lib/jsutils/memoize3.js +1 -0
  47. package/lib/jsutils/naturalCompare.js +1 -0
  48. package/lib/jsutils/printPathArray.js +4 -1
  49. package/lib/jsutils/printPathArray.mjs +3 -1
  50. package/lib/jsutils/promiseForObject.js +1 -0
  51. package/lib/jsutils/promiseReduce.js +1 -0
  52. package/lib/jsutils/suggestionList.js +9 -1
  53. package/lib/jsutils/suggestionList.mjs +8 -1
  54. package/lib/jsutils/toObjMap.js +1 -0
  55. package/lib/subscribeWithSchema.js +1 -0
  56. package/lib/subscribeWithoutSchema.js +45 -6
  57. package/lib/subscribeWithoutSchema.mjs +44 -6
  58. package/lib/transforms/annotateDocumentGraphQLTransform.js +1 -0
  59. package/lib/types.js +1 -0
  60. package/lib/utilities/blankGraphQLTag.js +1 -0
  61. package/lib/utilities/mapAsyncIterator.js +1 -0
  62. package/lib/utilities/mergeResolvers.js +1 -0
  63. package/lib/utilities/typeNameFromAST.js +1 -0
  64. package/lib/values.js +82 -21
  65. package/lib/values.mjs +81 -21
  66. 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(resolvers, varDefNodes, inputs, (error) => {
26
- if (maxErrors != null && errors.length >= maxErrors) {
27
- throw new GraphQLError("Too many errors processing variables, error limit reached. Execution aborted.");
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
- errors.push(error);
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(new GraphQLError(`Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`, varDefNode.type));
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(varDefNode.defaultValue, varType);
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(new GraphQLError(`Variable "$${varName}" of required type "${varTypeStr}" was not provided.`, varDefNode));
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(new GraphQLError(`Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`, varDefNode));
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(value, varType, (path, invalidValue, error) => {
66
- let prefix = `Variable "$${varName}" got invalid value ` + inspect(invalidValue);
67
- if (path.length > 0) {
68
- prefix += ` at "${varName}${printPathArray(path)}"`;
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
- onError(new GraphQLError(prefix + "; " + error.message, varDefNode, void 0, void 0, void 0, error.originalError));
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(argumentNodes, (arg) => arg.name.value);
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(`Argument "$${name}" expected value of type "${inspect(argType)}" which cannot be used as an input type.`, argumentNode);
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(`Argument "${name}" of required type "${inspect(argType)}" was provided the variable "$${variableName}" which was not provided a runtime value.`, valueNode);
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(valueNode, argType, variableValues);
151
+ const coercedValue = valueFromAST(
152
+ valueNode,
153
+ argType,
154
+ variableValues
155
+ );
103
156
  if (coercedValue === void 0) {
104
- throw new GraphQLError(`Argument "${name}" has invalid value ${print(valueNode)}.`, valueNode);
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((directive) => directive.name.value === directiveDef.name);
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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@graphitation/supermassive",
3
3
  "license": "MIT",
4
- "version": "2.2.1",
4
+ "version": "2.2.3",
5
5
  "main": "./lib/index",
6
6
  "repository": {
7
7
  "type": "git",