graphql 16.10.0 → 16.11.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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![GraphQLConf 2024 Banner: September 10-12, San Francisco. Hosted by the GraphQL Foundation](https://github.com/user-attachments/assets/2d048502-e5b2-4e9d-a02a-50b841824de6)](https://graphql.org/conf/2024/?utm_source=github&utm_medium=graphql_js&utm_campaign=readme)
1
+ [![GraphQLConf 2025 Banner: September 08-10, Amsterdam. Hosted by the GraphQL Foundation](./assets/graphql-conf-2025.png)](https://graphql.org/conf/2025/?utm_source=github&utm_medium=graphql_js&utm_campaign=readme)
2
2
 
3
3
  # GraphQL.js
4
4
 
@@ -92,6 +92,11 @@ export interface ExecutionArgs {
92
92
  fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
93
93
  typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
94
94
  subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
95
+ /** Additional execution options. */
96
+ options?: {
97
+ /** Set the maximum number of errors allowed for coercing (defaults to 50). */
98
+ maxCoercionErrors?: number;
99
+ };
95
100
  }
96
101
  /**
97
102
  * Implements the "Executing requests" section of the GraphQL specification.
@@ -210,7 +210,7 @@ function assertValidExecutionArguments(schema, document, rawVariableValues) {
210
210
  */
211
211
 
212
212
  function buildExecutionContext(args) {
213
- var _definition$name, _operation$variableDe;
213
+ var _definition$name, _operation$variableDe, _options$maxCoercionE;
214
214
 
215
215
  const {
216
216
  schema,
@@ -222,6 +222,7 @@ function buildExecutionContext(args) {
222
222
  fieldResolver,
223
223
  typeResolver,
224
224
  subscribeFieldResolver,
225
+ options,
225
226
  } = args;
226
227
  let operation;
227
228
  const fragments = Object.create(null);
@@ -284,7 +285,14 @@ function buildExecutionContext(args) {
284
285
  ? rawVariableValues
285
286
  : {},
286
287
  {
287
- maxErrors: 50,
288
+ maxErrors:
289
+ (_options$maxCoercionE =
290
+ options === null || options === void 0
291
+ ? void 0
292
+ : options.maxCoercionErrors) !== null &&
293
+ _options$maxCoercionE !== void 0
294
+ ? _options$maxCoercionE
295
+ : 50,
288
296
  },
289
297
  );
290
298
 
@@ -195,7 +195,7 @@ export function assertValidExecutionArguments(
195
195
  */
196
196
 
197
197
  export function buildExecutionContext(args) {
198
- var _definition$name, _operation$variableDe;
198
+ var _definition$name, _operation$variableDe, _options$maxCoercionE;
199
199
 
200
200
  const {
201
201
  schema,
@@ -207,6 +207,7 @@ export function buildExecutionContext(args) {
207
207
  fieldResolver,
208
208
  typeResolver,
209
209
  subscribeFieldResolver,
210
+ options,
210
211
  } = args;
211
212
  let operation;
212
213
  const fragments = Object.create(null);
@@ -265,7 +266,14 @@ export function buildExecutionContext(args) {
265
266
  ? rawVariableValues
266
267
  : {},
267
268
  {
268
- maxErrors: 50,
269
+ maxErrors:
270
+ (_options$maxCoercionE =
271
+ options === null || options === void 0
272
+ ? void 0
273
+ : options.maxCoercionErrors) !== null &&
274
+ _options$maxCoercionE !== void 0
275
+ ? _options$maxCoercionE
276
+ : 50,
269
277
  },
270
278
  );
271
279
 
@@ -145,10 +145,7 @@ function visit(root, visitor, visitorKeys = _ast.QueryDocumentKeys) {
145
145
  }
146
146
  }
147
147
  } else {
148
- node = Object.defineProperties(
149
- {},
150
- Object.getOwnPropertyDescriptors(node),
151
- );
148
+ node = { ...node };
152
149
 
153
150
  for (const [editKey, editValue] of edits) {
154
151
  node[editKey] = editValue;
@@ -133,10 +133,7 @@ export function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
133
133
  }
134
134
  }
135
135
  } else {
136
- node = Object.defineProperties(
137
- {},
138
- Object.getOwnPropertyDescriptors(node),
139
- );
136
+ node = { ...node };
140
137
 
141
138
  for (const [editKey, editValue] of edits) {
142
139
  node[editKey] = editValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql",
3
- "version": "16.10.0",
3
+ "version": "16.11.0",
4
4
  "description": "A Query Language and Runtime which can target any service.",
5
5
  "license": "MIT",
6
6
  "main": "index",
@@ -80,7 +80,10 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
80
80
  }
81
81
 
82
82
  if ((0, _definition.isInputObjectType)(type)) {
83
- if (!(0, _isObjectLike.isObjectLike)(inputValue)) {
83
+ if (
84
+ !(0, _isObjectLike.isObjectLike)(inputValue) ||
85
+ Array.isArray(inputValue)
86
+ ) {
84
87
  onError(
85
88
  (0, _Path.pathToArray)(path),
86
89
  inputValue,
@@ -67,7 +67,7 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
67
67
  }
68
68
 
69
69
  if (isInputObjectType(type)) {
70
- if (!isObjectLike(inputValue)) {
70
+ if (!isObjectLike(inputValue) || Array.isArray(inputValue)) {
71
71
  onError(
72
72
  pathToArray(path),
73
73
  inputValue,
@@ -27,6 +27,7 @@ interface VariableUsage {
27
27
  readonly node: VariableNode;
28
28
  readonly type: Maybe<GraphQLInputType>;
29
29
  readonly defaultValue: Maybe<unknown>;
30
+ readonly parentType: Maybe<GraphQLInputType>;
30
31
  }
31
32
  /**
32
33
  * An instance of this class is passed as the "this" context to all validators,
@@ -168,6 +168,7 @@ class ValidationContext extends ASTValidationContext {
168
168
  node: variable,
169
169
  type: typeInfo.getInputType(),
170
170
  defaultValue: typeInfo.getDefaultValue(),
171
+ parentType: typeInfo.getParentInputType(),
171
172
  });
172
173
  },
173
174
  }),
@@ -150,6 +150,7 @@ export class ValidationContext extends ASTValidationContext {
150
150
  node: variable,
151
151
  type: typeInfo.getInputType(),
152
152
  defaultValue: typeInfo.getDefaultValue(),
153
+ parentType: typeInfo.getParentInputType(),
153
154
  });
154
155
  },
155
156
  }),
@@ -35,7 +35,7 @@ function VariablesInAllowedPositionRule(context) {
35
35
  leave(operation) {
36
36
  const usages = context.getRecursiveVariableUsages(operation);
37
37
 
38
- for (const { node, type, defaultValue } of usages) {
38
+ for (const { node, type, defaultValue, parentType } of usages) {
39
39
  const varName = node.name.value;
40
40
  const varDef = varDefMap[varName];
41
41
 
@@ -69,6 +69,21 @@ function VariablesInAllowedPositionRule(context) {
69
69
  ),
70
70
  );
71
71
  }
72
+
73
+ if (
74
+ (0, _definition.isInputObjectType)(parentType) &&
75
+ parentType.isOneOf &&
76
+ (0, _definition.isNullableType)(varType)
77
+ ) {
78
+ context.reportError(
79
+ new _GraphQLError.GraphQLError(
80
+ `Variable "$${varName}" is of type "${varType}" but must be non-nullable to be used for OneOf Input Object "${parentType}".`,
81
+ {
82
+ nodes: [varDef, node],
83
+ },
84
+ ),
85
+ );
86
+ }
72
87
  }
73
88
  }
74
89
  },
@@ -1,7 +1,11 @@
1
1
  import { inspect } from '../../jsutils/inspect.mjs';
2
2
  import { GraphQLError } from '../../error/GraphQLError.mjs';
3
3
  import { Kind } from '../../language/kinds.mjs';
4
- import { isNonNullType } from '../../type/definition.mjs';
4
+ import {
5
+ isInputObjectType,
6
+ isNonNullType,
7
+ isNullableType,
8
+ } from '../../type/definition.mjs';
5
9
  import { isTypeSubTypeOf } from '../../utilities/typeComparators.mjs';
6
10
  import { typeFromAST } from '../../utilities/typeFromAST.mjs';
7
11
 
@@ -23,7 +27,7 @@ export function VariablesInAllowedPositionRule(context) {
23
27
  leave(operation) {
24
28
  const usages = context.getRecursiveVariableUsages(operation);
25
29
 
26
- for (const { node, type, defaultValue } of usages) {
30
+ for (const { node, type, defaultValue, parentType } of usages) {
27
31
  const varName = node.name.value;
28
32
  const varDef = varDefMap[varName];
29
33
 
@@ -57,6 +61,21 @@ export function VariablesInAllowedPositionRule(context) {
57
61
  ),
58
62
  );
59
63
  }
64
+
65
+ if (
66
+ isInputObjectType(parentType) &&
67
+ parentType.isOneOf &&
68
+ isNullableType(varType)
69
+ ) {
70
+ context.reportError(
71
+ new GraphQLError(
72
+ `Variable "$${varName}" is of type "${varType}" but must be non-nullable to be used for OneOf Input Object "${parentType}".`,
73
+ {
74
+ nodes: [varDef, node],
75
+ },
76
+ ),
77
+ );
78
+ }
60
79
  }
61
80
  }
62
81
  },
package/version.js CHANGED
@@ -10,7 +10,7 @@ exports.versionInfo = exports.version = void 0;
10
10
  /**
11
11
  * A string containing the version of the GraphQL.js library
12
12
  */
13
- const version = '16.10.0';
13
+ const version = '16.11.0';
14
14
  /**
15
15
  * An object containing the components of the GraphQL.js version string
16
16
  */
@@ -18,7 +18,7 @@ const version = '16.10.0';
18
18
  exports.version = version;
19
19
  const versionInfo = Object.freeze({
20
20
  major: 16,
21
- minor: 10,
21
+ minor: 11,
22
22
  patch: 0,
23
23
  preReleaseTag: null,
24
24
  });
package/version.mjs CHANGED
@@ -4,14 +4,14 @@
4
4
  /**
5
5
  * A string containing the version of the GraphQL.js library
6
6
  */
7
- export const version = '16.10.0';
7
+ export const version = '16.11.0';
8
8
  /**
9
9
  * An object containing the components of the GraphQL.js version string
10
10
  */
11
11
 
12
12
  export const versionInfo = Object.freeze({
13
13
  major: 16,
14
- minor: 10,
14
+ minor: 11,
15
15
  patch: 0,
16
16
  preReleaseTag: null,
17
17
  });