graphql 15.10.3 → 15.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.
Files changed (99) hide show
  1. package/error/GraphQLError.js +7 -6
  2. package/error/GraphQLError.js.flow +3 -3
  3. package/error/GraphQLError.mjs +8 -7
  4. package/execution/execute.d.ts +2 -0
  5. package/execution/execute.js +33 -12
  6. package/execution/execute.js.flow +32 -11
  7. package/execution/execute.mjs +33 -12
  8. package/execution/values.d.ts +1 -1
  9. package/execution/values.js +5 -5
  10. package/execution/values.js.flow +5 -2
  11. package/execution/values.mjs +4 -4
  12. package/graphql.d.ts +1 -0
  13. package/graphql.js +4 -1
  14. package/graphql.js.flow +5 -1
  15. package/graphql.mjs +4 -1
  16. package/jsutils/SetMap.js +56 -0
  17. package/jsutils/SetMap.js.flow +39 -0
  18. package/jsutils/SetMap.mjs +47 -0
  19. package/language/lexer.js +21 -2
  20. package/language/lexer.js.flow +24 -2
  21. package/language/lexer.mjs +21 -2
  22. package/language/location.d.ts +5 -0
  23. package/language/location.js +64 -0
  24. package/language/location.js.flow +39 -0
  25. package/language/location.mjs +62 -0
  26. package/language/parser.js +34 -19
  27. package/language/parser.js.flow +54 -10
  28. package/language/parser.mjs +34 -19
  29. package/language/printer.d.ts +7 -0
  30. package/language/printer.js +251 -118
  31. package/language/printer.js.flow +345 -141
  32. package/language/printer.mjs +246 -116
  33. package/language/reducer.js +99 -0
  34. package/language/reducer.js.flow +89 -0
  35. package/language/reducer.mjs +89 -0
  36. package/package.json +1 -1
  37. package/subscription/subscribe.d.ts +2 -0
  38. package/subscription/subscribe.js +4 -3
  39. package/subscription/subscribe.js.flow +6 -0
  40. package/subscription/subscribe.mjs +4 -3
  41. package/type/definition.d.ts +2 -1
  42. package/type/definition.js +8 -8
  43. package/type/definition.js.flow +13 -7
  44. package/type/definition.mjs +7 -7
  45. package/type/scalars.js +5 -5
  46. package/type/scalars.js.flow +1 -1
  47. package/type/scalars.mjs +1 -1
  48. package/utilities/buildASTSchema.js +3 -0
  49. package/utilities/buildASTSchema.js.flow +3 -0
  50. package/utilities/buildASTSchema.mjs +3 -0
  51. package/utilities/coerceInputValue.d.ts +1 -0
  52. package/utilities/coerceInputValue.js +9 -8
  53. package/utilities/coerceInputValue.js.flow +42 -9
  54. package/utilities/coerceInputValue.mjs +10 -9
  55. package/utilities/findBreakingChanges.js +3 -23
  56. package/utilities/findBreakingChanges.js.flow +2 -15
  57. package/utilities/findBreakingChanges.mjs +2 -21
  58. package/utilities/sortValueNode.js +52 -0
  59. package/utilities/sortValueNode.js.flow +42 -0
  60. package/utilities/sortValueNode.mjs +42 -0
  61. package/utilities/valueFromAST.js +2 -2
  62. package/utilities/valueFromAST.js.flow +8 -2
  63. package/utilities/valueFromAST.mjs +2 -2
  64. package/validation/ValidationContext.d.ts +8 -0
  65. package/validation/ValidationContext.js +82 -24
  66. package/validation/ValidationContext.js.flow +70 -21
  67. package/validation/ValidationContext.mjs +80 -24
  68. package/validation/rules/FieldsOnCorrectTypeRule.js +2 -2
  69. package/validation/rules/FieldsOnCorrectTypeRule.js.flow +8 -2
  70. package/validation/rules/FieldsOnCorrectTypeRule.mjs +2 -2
  71. package/validation/rules/KnownArgumentNamesRule.js +8 -9
  72. package/validation/rules/KnownArgumentNamesRule.js.flow +16 -6
  73. package/validation/rules/KnownArgumentNamesRule.mjs +8 -9
  74. package/validation/rules/KnownTypeNamesRule.js +1 -1
  75. package/validation/rules/KnownTypeNamesRule.js.flow +6 -4
  76. package/validation/rules/KnownTypeNamesRule.mjs +1 -1
  77. package/validation/rules/MaxIntrospectionDepthRule.js +37 -17
  78. package/validation/rules/MaxIntrospectionDepthRule.js.flow +46 -15
  79. package/validation/rules/MaxIntrospectionDepthRule.mjs +37 -17
  80. package/validation/rules/NoUnusedFragmentsRule.js +6 -13
  81. package/validation/rules/NoUnusedFragmentsRule.js.flow +6 -10
  82. package/validation/rules/NoUnusedFragmentsRule.mjs +6 -13
  83. package/validation/rules/OverlappingFieldsCanBeMergedRule.js +402 -208
  84. package/validation/rules/OverlappingFieldsCanBeMergedRule.js.flow +566 -330
  85. package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +400 -206
  86. package/validation/rules/ValuesOfCorrectTypeRule.js +6 -6
  87. package/validation/rules/ValuesOfCorrectTypeRule.js.flow +11 -6
  88. package/validation/rules/ValuesOfCorrectTypeRule.mjs +4 -4
  89. package/validation/validate.d.ts +1 -1
  90. package/validation/validate.js +6 -2
  91. package/validation/validate.js.flow +8 -2
  92. package/validation/validate.mjs +5 -2
  93. package/validation/validationAbortedError.d.ts +4 -0
  94. package/validation/validationAbortedError.js +12 -0
  95. package/validation/validationAbortedError.js.flow +7 -0
  96. package/validation/validationAbortedError.mjs +4 -0
  97. package/version.js +3 -3
  98. package/version.js.flow +3 -3
  99. package/version.mjs +3 -3
@@ -69,7 +69,7 @@ function ValuesOfCorrectTypeRule(context) {
69
69
  var fieldType = context.getInputType();
70
70
 
71
71
  if (!fieldType && (0, _definition.isInputObjectType)(parentType)) {
72
- var suggestions = (0, _suggestionList.default)(node.name.value, Object.keys(parentType.getFields()));
72
+ var suggestions = context.hideSuggestions ? [] : (0, _suggestionList.default)(node.name.value, Object.keys(parentType.getFields()));
73
73
  context.reportError(new _GraphQLError.GraphQLError("Field \"".concat(node.name.value, "\" is not defined by type \"").concat(parentType.name, "\".") + (0, _didYouMean.default)(suggestions), node));
74
74
  }
75
75
  },
@@ -77,7 +77,7 @@ function ValuesOfCorrectTypeRule(context) {
77
77
  var type = context.getInputType();
78
78
 
79
79
  if ((0, _definition.isNonNullType)(type)) {
80
- context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat((0, _inspect.default)(type), "\", found ").concat((0, _printer.print)(node), "."), node));
80
+ context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat((0, _inspect.default)(type), "\", found ").concat((0, _printer.printForError)(node), "."), node));
81
81
  }
82
82
  },
83
83
  EnumValue: function EnumValue(node) {
@@ -115,21 +115,21 @@ function isValidValueNode(context, node) {
115
115
 
116
116
  if (!(0, _definition.isLeafType)(type)) {
117
117
  var typeStr = (0, _inspect.default)(locationType);
118
- context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat(typeStr, "\", found ").concat((0, _printer.print)(node), "."), node));
118
+ context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat(typeStr, "\", found ").concat((0, _printer.printForError)(node), "."), node));
119
119
  return;
120
120
  } // Scalars and Enums determine if a literal value is valid via parseLiteral(),
121
121
  // which may throw or return an invalid value to indicate failure.
122
122
 
123
123
 
124
124
  try {
125
- var parseResult = type.parseLiteral(node, undefined
125
+ var parseResult = (0, _definition.isEnumType)(type) ? type.parseLiteral(node, undefined, context.hideSuggestions) : type.parseLiteral(node, undefined
126
126
  /* variables */
127
127
  );
128
128
 
129
129
  if (parseResult === undefined) {
130
130
  var _typeStr = (0, _inspect.default)(locationType);
131
131
 
132
- context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat(_typeStr, "\", found ").concat((0, _printer.print)(node), "."), node));
132
+ context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat(_typeStr, "\", found ").concat((0, _printer.printForError)(node), "."), node));
133
133
  }
134
134
  } catch (error) {
135
135
  var _typeStr2 = (0, _inspect.default)(locationType);
@@ -137,7 +137,7 @@ function isValidValueNode(context, node) {
137
137
  if (error instanceof _GraphQLError.GraphQLError) {
138
138
  context.reportError(error);
139
139
  } else {
140
- context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat(_typeStr2, "\", found ").concat((0, _printer.print)(node), "; ") + error.message, node, undefined, undefined, undefined, error));
140
+ context.reportError(new _GraphQLError.GraphQLError("Expected value of type \"".concat(_typeStr2, "\", found ").concat((0, _printer.printForError)(node), "; ") + error.message, node, undefined, undefined, undefined, error));
141
141
  }
142
142
  }
143
143
  }
@@ -10,11 +10,12 @@ import { GraphQLError } from '../../error/GraphQLError';
10
10
 
11
11
  import type { ValueNode } from '../../language/ast';
12
12
  import type { ASTVisitor } from '../../language/visitor';
13
- import { print } from '../../language/printer';
13
+ import { printForError as print } from '../../language/printer';
14
14
 
15
15
  import {
16
16
  isLeafType,
17
17
  isInputObjectType,
18
+ isEnumType,
18
19
  isListType,
19
20
  isNonNullType,
20
21
  isRequiredInputField,
@@ -68,10 +69,12 @@ export function ValuesOfCorrectTypeRule(
68
69
  const parentType = getNamedType(context.getParentInputType());
69
70
  const fieldType = context.getInputType();
70
71
  if (!fieldType && isInputObjectType(parentType)) {
71
- const suggestions = suggestionList(
72
- node.name.value,
73
- Object.keys(parentType.getFields()),
74
- );
72
+ const suggestions = context.hideSuggestions
73
+ ? []
74
+ : suggestionList(
75
+ node.name.value,
76
+ Object.keys(parentType.getFields()),
77
+ );
75
78
  context.reportError(
76
79
  new GraphQLError(
77
80
  `Field "${node.name.value}" is not defined by type "${parentType.name}".` +
@@ -127,7 +130,9 @@ function isValidValueNode(context: ValidationContext, node: ValueNode): void {
127
130
  // Scalars and Enums determine if a literal value is valid via parseLiteral(),
128
131
  // which may throw or return an invalid value to indicate failure.
129
132
  try {
130
- const parseResult = type.parseLiteral(node, undefined /* variables */);
133
+ const parseResult = isEnumType(type)
134
+ ? type.parseLiteral(node, undefined, context.hideSuggestions)
135
+ : type.parseLiteral(node, undefined /* variables */);
131
136
  if (parseResult === undefined) {
132
137
  const typeStr = inspect(locationType);
133
138
  context.reportError(
@@ -4,8 +4,8 @@ import inspect from "../../jsutils/inspect.mjs";
4
4
  import didYouMean from "../../jsutils/didYouMean.mjs";
5
5
  import suggestionList from "../../jsutils/suggestionList.mjs";
6
6
  import { GraphQLError } from "../../error/GraphQLError.mjs";
7
- import { print } from "../../language/printer.mjs";
8
- import { isLeafType, isInputObjectType, isListType, isNonNullType, isRequiredInputField, getNullableType, getNamedType } from "../../type/definition.mjs";
7
+ import { printForError as print } from "../../language/printer.mjs";
8
+ import { isLeafType, isInputObjectType, isEnumType, isListType, isNonNullType, isRequiredInputField, getNullableType, getNamedType } from "../../type/definition.mjs";
9
9
 
10
10
  /**
11
11
  * Value literals of correct type
@@ -53,7 +53,7 @@ export function ValuesOfCorrectTypeRule(context) {
53
53
  var fieldType = context.getInputType();
54
54
 
55
55
  if (!fieldType && isInputObjectType(parentType)) {
56
- var suggestions = suggestionList(node.name.value, Object.keys(parentType.getFields()));
56
+ var suggestions = context.hideSuggestions ? [] : suggestionList(node.name.value, Object.keys(parentType.getFields()));
57
57
  context.reportError(new GraphQLError("Field \"".concat(node.name.value, "\" is not defined by type \"").concat(parentType.name, "\".") + didYouMean(suggestions), node));
58
58
  }
59
59
  },
@@ -105,7 +105,7 @@ function isValidValueNode(context, node) {
105
105
 
106
106
 
107
107
  try {
108
- var parseResult = type.parseLiteral(node, undefined
108
+ var parseResult = isEnumType(type) ? type.parseLiteral(node, undefined, context.hideSuggestions) : type.parseLiteral(node, undefined
109
109
  /* variables */
110
110
  );
111
111
 
@@ -31,7 +31,7 @@ export function validate(
31
31
  documentAST: DocumentNode,
32
32
  rules?: ReadonlyArray<ValidationRule>,
33
33
  typeInfo?: TypeInfo,
34
- options?: { maxErrors?: number },
34
+ options?: { maxErrors?: number; hideSuggestions?: boolean | null },
35
35
  ): ReadonlyArray<GraphQLError>;
36
36
 
37
37
  /**
@@ -20,6 +20,8 @@ var _TypeInfo = require("../utilities/TypeInfo.js");
20
20
 
21
21
  var _specifiedRules = require("./specifiedRules.js");
22
22
 
23
+ var _validationAbortedError = require("./validationAbortedError.js");
24
+
23
25
  var _ValidationContext = require("./ValidationContext.js");
24
26
 
25
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -58,7 +60,7 @@ function validate(schema, documentAST) {
58
60
  }
59
61
 
60
62
  errors.push(error);
61
- }); // This uses a specialized visitor which runs multiple visitors in parallel,
63
+ }, options.hideSuggestions); // This uses a specialized visitor which runs multiple visitors in parallel,
62
64
  // while maintaining the visitor skip and break API.
63
65
 
64
66
  var visitor = (0, _visitor.visitInParallel)(rules.map(function (rule) {
@@ -68,7 +70,9 @@ function validate(schema, documentAST) {
68
70
  try {
69
71
  (0, _visitor.visit)(documentAST, (0, _TypeInfo.visitWithTypeInfo)(typeInfo, visitor));
70
72
  } catch (e) {
71
- if (e !== abortObj) {
73
+ if (e === _validationAbortedError.validationAbortedError) {
74
+ errors.push(_validationAbortedError.validationAbortedError);
75
+ } else if (e !== abortObj) {
72
76
  throw e;
73
77
  }
74
78
  }
@@ -13,6 +13,7 @@ import { TypeInfo, visitWithTypeInfo } from '../utilities/TypeInfo';
13
13
 
14
14
  import type { SDLValidationRule, ValidationRule } from './ValidationContext';
15
15
  import { specifiedRules, specifiedSDLRules } from './specifiedRules';
16
+ import { validationAbortedError } from './validationAbortedError';
16
17
  import { SDLValidationContext, ValidationContext } from './ValidationContext';
17
18
 
18
19
  /**
@@ -36,7 +37,9 @@ export function validate(
36
37
  documentAST: DocumentNode,
37
38
  rules: $ReadOnlyArray<ValidationRule> = specifiedRules,
38
39
  typeInfo: TypeInfo = new TypeInfo(schema),
39
- options: {| maxErrors?: number |} = { maxErrors: undefined },
40
+ options: $ReadOnly<{| maxErrors?: number, hideSuggestions?: ?boolean |}> = {
41
+ maxErrors: undefined,
42
+ },
40
43
  ): $ReadOnlyArray<GraphQLError> {
41
44
  devAssert(documentAST, 'Must provide document.');
42
45
  // If the schema used for validation is invalid, throw an error.
@@ -59,6 +62,7 @@ export function validate(
59
62
  }
60
63
  errors.push(error);
61
64
  },
65
+ options.hideSuggestions,
62
66
  );
63
67
 
64
68
  // This uses a specialized visitor which runs multiple visitors in parallel,
@@ -69,7 +73,9 @@ export function validate(
69
73
  try {
70
74
  visit(documentAST, visitWithTypeInfo(typeInfo, visitor));
71
75
  } catch (e) {
72
- if (e !== abortObj) {
76
+ if (e === validationAbortedError) {
77
+ errors.push(validationAbortedError);
78
+ } else if (e !== abortObj) {
73
79
  throw e;
74
80
  }
75
81
  }
@@ -4,6 +4,7 @@ import { visit, visitInParallel } from "../language/visitor.mjs";
4
4
  import { assertValidSchema } from "../type/validate.mjs";
5
5
  import { TypeInfo, visitWithTypeInfo } from "../utilities/TypeInfo.mjs";
6
6
  import { specifiedRules, specifiedSDLRules } from "./specifiedRules.mjs";
7
+ import { validationAbortedError } from "./validationAbortedError.mjs";
7
8
  import { SDLValidationContext, ValidationContext } from "./ValidationContext.mjs";
8
9
  /**
9
10
  * Implements the "Validation" section of the spec.
@@ -40,7 +41,7 @@ export function validate(schema, documentAST) {
40
41
  }
41
42
 
42
43
  errors.push(error);
43
- }); // This uses a specialized visitor which runs multiple visitors in parallel,
44
+ }, options.hideSuggestions); // This uses a specialized visitor which runs multiple visitors in parallel,
44
45
  // while maintaining the visitor skip and break API.
45
46
 
46
47
  var visitor = visitInParallel(rules.map(function (rule) {
@@ -50,7 +51,9 @@ export function validate(schema, documentAST) {
50
51
  try {
51
52
  visit(documentAST, visitWithTypeInfo(typeInfo, visitor));
52
53
  } catch (e) {
53
- if (e !== abortObj) {
54
+ if (e === validationAbortedError) {
55
+ errors.push(validationAbortedError);
56
+ } else if (e !== abortObj) {
54
57
  throw e;
55
58
  }
56
59
  }
@@ -0,0 +1,4 @@
1
+ import { GraphQLError } from '../error/GraphQLError';
2
+
3
+ /** @internal */
4
+ export const validationAbortedError: GraphQLError;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validationAbortedError = void 0;
7
+
8
+ var _GraphQLError = require("../error/GraphQLError.js");
9
+
10
+ /** @internal */
11
+ var validationAbortedError = new _GraphQLError.GraphQLError('Validation aborted.');
12
+ exports.validationAbortedError = validationAbortedError;
@@ -0,0 +1,7 @@
1
+ // @flow strict
2
+ import { GraphQLError } from '../error/GraphQLError';
3
+
4
+ /** @internal */
5
+ export const validationAbortedError: GraphQLError = new GraphQLError(
6
+ 'Validation aborted.',
7
+ );
@@ -0,0 +1,4 @@
1
+ import { GraphQLError } from "../error/GraphQLError.mjs";
2
+ /** @internal */
3
+
4
+ export var validationAbortedError = new GraphQLError('Validation aborted.');
package/version.js CHANGED
@@ -13,7 +13,7 @@ exports.versionInfo = exports.version = void 0;
13
13
  /**
14
14
  * A string containing the version of the GraphQL.js library
15
15
  */
16
- var version = '15.10.3';
16
+ var version = '15.11.0';
17
17
  /**
18
18
  * An object containing the components of the GraphQL.js version string
19
19
  */
@@ -21,8 +21,8 @@ var version = '15.10.3';
21
21
  exports.version = version;
22
22
  var versionInfo = Object.freeze({
23
23
  major: 15,
24
- minor: 10,
25
- patch: 3,
24
+ minor: 11,
25
+ patch: 0,
26
26
  preReleaseTag: null
27
27
  });
28
28
  exports.versionInfo = versionInfo;
package/version.js.flow CHANGED
@@ -7,14 +7,14 @@
7
7
  /**
8
8
  * A string containing the version of the GraphQL.js library
9
9
  */
10
- export const version = '15.10.3';
10
+ export const version = '15.11.0';
11
11
 
12
12
  /**
13
13
  * An object containing the components of the GraphQL.js version string
14
14
  */
15
15
  export const versionInfo = Object.freeze({
16
16
  major: 15,
17
- minor: 10,
18
- patch: 3,
17
+ minor: 11,
18
+ patch: 0,
19
19
  preReleaseTag: null,
20
20
  });
package/version.mjs CHANGED
@@ -6,14 +6,14 @@
6
6
  /**
7
7
  * A string containing the version of the GraphQL.js library
8
8
  */
9
- export var version = '15.10.3';
9
+ export var version = '15.11.0';
10
10
  /**
11
11
  * An object containing the components of the GraphQL.js version string
12
12
  */
13
13
 
14
14
  export var versionInfo = Object.freeze({
15
15
  major: 15,
16
- minor: 10,
17
- patch: 3,
16
+ minor: 11,
17
+ patch: 0,
18
18
  preReleaseTag: null
19
19
  });