graphql 15.0.0 → 15.1.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 (164) hide show
  1. package/README.md +5 -5
  2. package/error/GraphQLError.d.ts +2 -2
  3. package/error/GraphQLError.js +4 -5
  4. package/error/GraphQLError.js.flow +1 -1
  5. package/error/GraphQLError.mjs +4 -5
  6. package/error/locatedError.d.ts +1 -1
  7. package/execution/execute.d.ts +8 -6
  8. package/execution/execute.js +4 -6
  9. package/execution/execute.js.flow +3 -2
  10. package/execution/execute.mjs +4 -6
  11. package/execution/values.d.ts +2 -1
  12. package/execution/values.js +1 -2
  13. package/execution/values.js.flow +1 -1
  14. package/execution/values.mjs +1 -2
  15. package/graphql.d.ts +2 -1
  16. package/index.d.ts +3 -2
  17. package/index.js +18 -0
  18. package/index.js.flow +3 -2
  19. package/index.mjs +2 -2
  20. package/jsutils/Maybe.d.ts +2 -0
  21. package/jsutils/Path.d.ts +2 -2
  22. package/jsutils/defineInspect.js +25 -0
  23. package/jsutils/defineInspect.js.flow +21 -0
  24. package/jsutils/defineInspect.mjs +15 -0
  25. package/jsutils/devAssert.js +1 -2
  26. package/jsutils/devAssert.js.flow +1 -1
  27. package/jsutils/devAssert.mjs +1 -2
  28. package/jsutils/instanceOf.js +1 -2
  29. package/jsutils/instanceOf.js.flow +1 -1
  30. package/jsutils/instanceOf.mjs +1 -2
  31. package/jsutils/invariant.js +1 -2
  32. package/jsutils/invariant.js.flow +1 -1
  33. package/jsutils/invariant.mjs +1 -2
  34. package/jsutils/nodejsCustomInspectSymbol.js +1 -2
  35. package/jsutils/nodejsCustomInspectSymbol.js.flow +1 -1
  36. package/jsutils/nodejsCustomInspectSymbol.mjs +1 -1
  37. package/language/ast.d.ts +11 -2
  38. package/language/ast.js +94 -80
  39. package/language/ast.js.flow +23 -14
  40. package/language/ast.mjs +86 -72
  41. package/language/blockString.js +2 -1
  42. package/language/blockString.js.flow +5 -1
  43. package/language/blockString.mjs +2 -1
  44. package/language/directiveLocation.d.ts +2 -7
  45. package/language/index.js +14 -0
  46. package/language/index.js.flow +1 -2
  47. package/language/index.mjs +1 -0
  48. package/language/kinds.d.ts +2 -7
  49. package/language/lexer.d.ts +6 -0
  50. package/language/tokenKind.d.ts +2 -4
  51. package/language/visitor.d.ts +4 -3
  52. package/package.json +2 -2
  53. package/polyfills/arrayFrom.js +1 -2
  54. package/polyfills/arrayFrom.js.flow +1 -1
  55. package/polyfills/arrayFrom.mjs +1 -2
  56. package/polyfills/symbols.js +3 -6
  57. package/polyfills/symbols.js.flow +3 -3
  58. package/polyfills/symbols.mjs +3 -6
  59. package/subscription/subscribe.d.ts +2 -1
  60. package/type/definition.d.ts +30 -21
  61. package/type/definition.js +60 -17
  62. package/type/definition.js.flow +61 -9
  63. package/type/definition.mjs +60 -17
  64. package/type/directives.d.ts +6 -1
  65. package/type/directives.js +28 -7
  66. package/type/directives.js.flow +23 -2
  67. package/type/directives.mjs +24 -4
  68. package/type/index.d.ts +1 -0
  69. package/type/index.js +6 -0
  70. package/type/index.js.flow +1 -0
  71. package/type/index.mjs +1 -1
  72. package/type/introspection.js +11 -6
  73. package/type/introspection.js.flow +8 -2
  74. package/type/introspection.mjs +11 -6
  75. package/type/schema.d.ts +7 -5
  76. package/type/validate.js +22 -8
  77. package/type/validate.js.flow +23 -11
  78. package/type/validate.mjs +22 -8
  79. package/utilities/TypeInfo.d.ts +2 -1
  80. package/utilities/astFromValue.d.ts +2 -1
  81. package/utilities/astFromValue.js +4 -5
  82. package/utilities/astFromValue.js.flow +2 -1
  83. package/utilities/astFromValue.mjs +4 -5
  84. package/utilities/buildASTSchema.js +15 -4
  85. package/utilities/buildASTSchema.js.flow +13 -2
  86. package/utilities/buildASTSchema.mjs +15 -4
  87. package/utilities/buildClientSchema.js +2 -1
  88. package/utilities/buildClientSchema.js.flow +1 -0
  89. package/utilities/buildClientSchema.mjs +2 -1
  90. package/utilities/coerceInputValue.js +4 -5
  91. package/utilities/coerceInputValue.js.flow +2 -1
  92. package/utilities/coerceInputValue.mjs +4 -5
  93. package/utilities/extendSchema.d.ts +2 -1
  94. package/utilities/extendSchema.js +78 -66
  95. package/utilities/extendSchema.js.flow +30 -9
  96. package/utilities/extendSchema.mjs +79 -67
  97. package/utilities/findBreakingChanges.d.ts +6 -16
  98. package/utilities/findBreakingChanges.js +5 -8
  99. package/utilities/findBreakingChanges.js.flow +2 -1
  100. package/utilities/findBreakingChanges.mjs +5 -8
  101. package/utilities/getIntrospectionQuery.d.ts +12 -2
  102. package/utilities/getIntrospectionQuery.js +3 -1
  103. package/utilities/getIntrospectionQuery.js.flow +10 -0
  104. package/utilities/getIntrospectionQuery.mjs +3 -1
  105. package/utilities/getOperationAST.d.ts +3 -2
  106. package/utilities/getOperationAST.js.flow +1 -1
  107. package/utilities/introspectionFromSchema.js +0 -2
  108. package/utilities/introspectionFromSchema.mjs +0 -2
  109. package/utilities/lexicographicSortSchema.js +14 -15
  110. package/utilities/lexicographicSortSchema.js.flow +2 -1
  111. package/utilities/lexicographicSortSchema.mjs +14 -15
  112. package/utilities/printSchema.js +16 -6
  113. package/utilities/printSchema.js.flow +20 -2
  114. package/utilities/printSchema.mjs +16 -6
  115. package/utilities/typeFromAST.js +4 -5
  116. package/utilities/typeFromAST.js.flow +2 -1
  117. package/utilities/typeFromAST.mjs +4 -5
  118. package/utilities/valueFromAST.d.ts +2 -1
  119. package/utilities/valueFromAST.js +4 -5
  120. package/utilities/valueFromAST.js.flow +2 -1
  121. package/utilities/valueFromAST.mjs +4 -5
  122. package/utilities/valueFromASTUntyped.d.ts +2 -1
  123. package/utilities/valueFromASTUntyped.js +2 -3
  124. package/utilities/valueFromASTUntyped.js.flow +1 -1
  125. package/utilities/valueFromASTUntyped.mjs +2 -3
  126. package/validation/ValidationContext.d.ts +4 -3
  127. package/validation/ValidationContext.js +0 -16
  128. package/validation/ValidationContext.mjs +0 -16
  129. package/validation/rules/KnownArgumentNamesRule.js +2 -2
  130. package/validation/rules/KnownArgumentNamesRule.js.flow +1 -1
  131. package/validation/rules/KnownArgumentNamesRule.mjs +2 -2
  132. package/validation/rules/KnownDirectivesRule.js +2 -5
  133. package/validation/rules/KnownDirectivesRule.js.flow +1 -1
  134. package/validation/rules/KnownDirectivesRule.mjs +2 -5
  135. package/validation/rules/KnownTypeNamesRule.d.ts +4 -2
  136. package/validation/rules/OverlappingFieldsCanBeMergedRule.js +2 -4
  137. package/validation/rules/OverlappingFieldsCanBeMergedRule.js.flow +2 -2
  138. package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +2 -4
  139. package/validation/rules/PossibleTypeExtensionsRule.js +6 -8
  140. package/validation/rules/PossibleTypeExtensionsRule.js.flow +3 -2
  141. package/validation/rules/PossibleTypeExtensionsRule.mjs +6 -8
  142. package/validation/rules/ProvidedRequiredArgumentsRule.js +4 -5
  143. package/validation/rules/ProvidedRequiredArgumentsRule.js.flow +3 -3
  144. package/validation/rules/ProvidedRequiredArgumentsRule.mjs +4 -5
  145. package/validation/rules/UniqueEnumValueNamesRule.js +1 -2
  146. package/validation/rules/UniqueEnumValueNamesRule.js.flow +1 -1
  147. package/validation/rules/UniqueEnumValueNamesRule.mjs +1 -2
  148. package/validation/rules/UniqueFieldDefinitionNamesRule.js +1 -2
  149. package/validation/rules/UniqueFieldDefinitionNamesRule.js.flow +1 -1
  150. package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +1 -2
  151. package/validation/rules/UniqueOperationTypesRule.js +1 -1
  152. package/validation/rules/UniqueOperationTypesRule.js.flow +1 -1
  153. package/validation/rules/UniqueOperationTypesRule.mjs +1 -1
  154. package/validation/validate.d.ts +3 -3
  155. package/version.js +3 -3
  156. package/version.js.flow +3 -3
  157. package/version.mjs +3 -3
  158. package/jsutils/dedent.js +0 -50
  159. package/jsutils/dedent.js.flow +0 -44
  160. package/jsutils/dedent.mjs +0 -43
  161. package/jsutils/defineToJSON.js +0 -25
  162. package/jsutils/defineToJSON.js.flow +0 -20
  163. package/jsutils/defineToJSON.mjs +0 -16
  164. package/tsutils/Maybe.d.ts +0 -6
package/language/ast.d.ts CHANGED
@@ -32,6 +32,8 @@ export class Location {
32
32
  readonly source: Source;
33
33
 
34
34
  constructor(startToken: Token, endToken: Token, source: Source);
35
+
36
+ toJSON(): { start: number; end: number };
35
37
  }
36
38
 
37
39
  /**
@@ -86,6 +88,13 @@ export class Token {
86
88
  prev: Token | null,
87
89
  value?: string,
88
90
  );
91
+
92
+ toJSON(): {
93
+ kind: TokenKindEnum;
94
+ value: string | undefined;
95
+ line: number;
96
+ column: number;
97
+ };
89
98
  }
90
99
 
91
100
  /**
@@ -526,12 +535,12 @@ export interface DirectiveDefinitionNode {
526
535
 
527
536
  export type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode;
528
537
 
529
- export type SchemaExtensionNode = {
538
+ export interface SchemaExtensionNode {
530
539
  readonly kind: 'SchemaExtension';
531
540
  readonly loc?: Location;
532
541
  readonly directives?: ReadonlyArray<DirectiveNode>;
533
542
  readonly operationTypes?: ReadonlyArray<OperationTypeDefinitionNode>;
534
- };
543
+ }
535
544
 
536
545
  // Type Extensions
537
546
 
package/language/ast.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.isNode = isNode;
7
7
  exports.Token = exports.Location = void 0;
8
8
 
9
- var _defineToJSON = _interopRequireDefault(require("../jsutils/defineToJSON"));
9
+ var _defineInspect = _interopRequireDefault(require("../jsutils/defineInspect"));
10
10
 
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
 
@@ -14,98 +14,112 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
14
14
  * Contains a range of UTF-8 character offsets and token references that
15
15
  * identify the region of the source from which the AST derived.
16
16
  */
17
- var Location =
18
- /**
19
- * The character offset at which this Node begins.
20
- */
21
-
22
- /**
23
- * The character offset at which this Node ends.
24
- */
25
-
26
- /**
27
- * The Token at which this Node begins.
28
- */
29
-
30
- /**
31
- * The Token at which this Node ends.
32
- */
17
+ var Location = /*#__PURE__*/function () {
18
+ /**
19
+ * The character offset at which this Node begins.
20
+ */
21
+
22
+ /**
23
+ * The character offset at which this Node ends.
24
+ */
25
+
26
+ /**
27
+ * The Token at which this Node begins.
28
+ */
29
+
30
+ /**
31
+ * The Token at which this Node ends.
32
+ */
33
+
34
+ /**
35
+ * The Source document the AST represents.
36
+ */
37
+ function Location(startToken, endToken, source) {
38
+ this.start = startToken.start;
39
+ this.end = endToken.end;
40
+ this.startToken = startToken;
41
+ this.endToken = endToken;
42
+ this.source = source;
43
+ }
44
+
45
+ var _proto = Location.prototype;
46
+
47
+ _proto.toJSON = function toJSON() {
48
+ return {
49
+ start: this.start,
50
+ end: this.end
51
+ };
52
+ };
33
53
 
34
- /**
35
- * The Source document the AST represents.
36
- */
37
- function Location(startToken, endToken, source) {
38
- this.start = startToken.start;
39
- this.end = endToken.end;
40
- this.startToken = startToken;
41
- this.endToken = endToken;
42
- this.source = source;
43
- }; // Print a simplified form when appearing in JSON/util.inspect.
54
+ return Location;
55
+ }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
44
56
 
45
57
 
46
58
  exports.Location = Location;
47
- (0, _defineToJSON.default)(Location, function () {
48
- return {
49
- start: this.start,
50
- end: this.end
51
- };
52
- });
59
+ (0, _defineInspect.default)(Location);
53
60
  /**
54
61
  * Represents a range of characters represented by a lexical token
55
62
  * within a Source.
56
63
  */
57
64
 
58
- var Token =
59
- /**
60
- * The kind of Token.
61
- */
62
-
63
- /**
64
- * The character offset at which this Node begins.
65
- */
66
-
67
- /**
68
- * The character offset at which this Node ends.
69
- */
70
-
71
- /**
72
- * The 1-indexed line number on which this Token appears.
73
- */
74
-
75
- /**
76
- * The 1-indexed column number at which this Token begins.
77
- */
65
+ var Token = /*#__PURE__*/function () {
66
+ /**
67
+ * The kind of Token.
68
+ */
69
+
70
+ /**
71
+ * The character offset at which this Node begins.
72
+ */
73
+
74
+ /**
75
+ * The character offset at which this Node ends.
76
+ */
77
+
78
+ /**
79
+ * The 1-indexed line number on which this Token appears.
80
+ */
81
+
82
+ /**
83
+ * The 1-indexed column number at which this Token begins.
84
+ */
85
+
86
+ /**
87
+ * For non-punctuation tokens, represents the interpreted value of the token.
88
+ */
89
+
90
+ /**
91
+ * Tokens exist as nodes in a double-linked-list amongst all tokens
92
+ * including ignored tokens. <SOF> is always the first node and <EOF>
93
+ * the last.
94
+ */
95
+ function Token(kind, start, end, line, column, prev, value) {
96
+ this.kind = kind;
97
+ this.start = start;
98
+ this.end = end;
99
+ this.line = line;
100
+ this.column = column;
101
+ this.value = value;
102
+ this.prev = prev;
103
+ this.next = null;
104
+ }
105
+
106
+ var _proto2 = Token.prototype;
107
+
108
+ _proto2.toJSON = function toJSON() {
109
+ return {
110
+ kind: this.kind,
111
+ value: this.value,
112
+ line: this.line,
113
+ column: this.column
114
+ };
115
+ };
78
116
 
79
- /**
80
- * For non-punctuation tokens, represents the interpreted value of the token.
81
- */
82
-
83
- /**
84
- * Tokens exist as nodes in a double-linked-list amongst all tokens
85
- * including ignored tokens. <SOF> is always the first node and <EOF>
86
- * the last.
87
- */
88
- function Token(kind, start, end, line, column, prev, value) {
89
- this.kind = kind;
90
- this.start = start;
91
- this.end = end;
92
- this.line = line;
93
- this.column = column;
94
- this.value = value;
95
- this.prev = prev;
96
- this.next = null;
97
- }; // Print a simplified form when appearing in JSON/util.inspect.
117
+ return Token;
118
+ }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
98
119
 
99
120
 
100
121
  exports.Token = Token;
101
- (0, _defineToJSON.default)(Token, function () {
102
- return {
103
- kind: this.kind,
104
- value: this.value,
105
- line: this.line,
106
- column: this.column
107
- };
108
- });
122
+ (0, _defineInspect.default)(Token);
109
123
  /**
110
124
  * @internal
111
125
  */
@@ -1,6 +1,6 @@
1
1
  // @flow strict
2
2
 
3
- import defineToJSON from '../jsutils/defineToJSON';
3
+ import defineInspect from '../jsutils/defineInspect';
4
4
 
5
5
  import { type Source } from './source';
6
6
  import { type TokenKindEnum } from './tokenKind';
@@ -42,12 +42,14 @@ export class Location {
42
42
  this.endToken = endToken;
43
43
  this.source = source;
44
44
  }
45
+
46
+ toJSON(): {| start: number, end: number |} {
47
+ return { start: this.start, end: this.end };
48
+ }
45
49
  }
46
50
 
47
- // Print a simplified form when appearing in JSON/util.inspect.
48
- defineToJSON(Location, function () {
49
- return { start: this.start, end: this.end };
50
- });
51
+ // Print a simplified form when appearing in `inspect` and `util.inspect`.
52
+ defineInspect(Location);
51
53
 
52
54
  /**
53
55
  * Represents a range of characters represented by a lexical token
@@ -110,17 +112,24 @@ export class Token {
110
112
  this.prev = prev;
111
113
  this.next = null;
112
114
  }
115
+
116
+ toJSON(): {|
117
+ kind: TokenKindEnum,
118
+ value: string | void,
119
+ line: number,
120
+ column: number,
121
+ |} {
122
+ return {
123
+ kind: this.kind,
124
+ value: this.value,
125
+ line: this.line,
126
+ column: this.column,
127
+ };
128
+ }
113
129
  }
114
130
 
115
- // Print a simplified form when appearing in JSON/util.inspect.
116
- defineToJSON(Token, function () {
117
- return {
118
- kind: this.kind,
119
- value: this.value,
120
- line: this.line,
121
- column: this.column,
122
- };
123
- });
131
+ // Print a simplified form when appearing in `inspect` and `util.inspect`.
132
+ defineInspect(Token);
124
133
 
125
134
  /**
126
135
  * @internal
package/language/ast.mjs CHANGED
@@ -1,97 +1,111 @@
1
- import defineToJSON from "../jsutils/defineToJSON.mjs";
1
+ import defineInspect from "../jsutils/defineInspect.mjs";
2
2
 
3
3
  /**
4
4
  * Contains a range of UTF-8 character offsets and token references that
5
5
  * identify the region of the source from which the AST derived.
6
6
  */
7
- export var Location =
8
- /**
9
- * The character offset at which this Node begins.
10
- */
7
+ export var Location = /*#__PURE__*/function () {
8
+ /**
9
+ * The character offset at which this Node begins.
10
+ */
11
11
 
12
- /**
13
- * The character offset at which this Node ends.
14
- */
12
+ /**
13
+ * The character offset at which this Node ends.
14
+ */
15
15
 
16
- /**
17
- * The Token at which this Node begins.
18
- */
16
+ /**
17
+ * The Token at which this Node begins.
18
+ */
19
19
 
20
- /**
21
- * The Token at which this Node ends.
22
- */
20
+ /**
21
+ * The Token at which this Node ends.
22
+ */
23
23
 
24
- /**
25
- * The Source document the AST represents.
26
- */
27
- function Location(startToken, endToken, source) {
28
- this.start = startToken.start;
29
- this.end = endToken.end;
30
- this.startToken = startToken;
31
- this.endToken = endToken;
32
- this.source = source;
33
- }; // Print a simplified form when appearing in JSON/util.inspect.
34
-
35
- defineToJSON(Location, function () {
36
- return {
37
- start: this.start,
38
- end: this.end
24
+ /**
25
+ * The Source document the AST represents.
26
+ */
27
+ function Location(startToken, endToken, source) {
28
+ this.start = startToken.start;
29
+ this.end = endToken.end;
30
+ this.startToken = startToken;
31
+ this.endToken = endToken;
32
+ this.source = source;
33
+ }
34
+
35
+ var _proto = Location.prototype;
36
+
37
+ _proto.toJSON = function toJSON() {
38
+ return {
39
+ start: this.start,
40
+ end: this.end
41
+ };
39
42
  };
40
- });
43
+
44
+ return Location;
45
+ }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
46
+
47
+ defineInspect(Location);
41
48
  /**
42
49
  * Represents a range of characters represented by a lexical token
43
50
  * within a Source.
44
51
  */
45
52
 
46
- export var Token =
47
- /**
48
- * The kind of Token.
49
- */
53
+ export var Token = /*#__PURE__*/function () {
54
+ /**
55
+ * The kind of Token.
56
+ */
50
57
 
51
- /**
52
- * The character offset at which this Node begins.
53
- */
58
+ /**
59
+ * The character offset at which this Node begins.
60
+ */
54
61
 
55
- /**
56
- * The character offset at which this Node ends.
57
- */
62
+ /**
63
+ * The character offset at which this Node ends.
64
+ */
58
65
 
59
- /**
60
- * The 1-indexed line number on which this Token appears.
61
- */
66
+ /**
67
+ * The 1-indexed line number on which this Token appears.
68
+ */
62
69
 
63
- /**
64
- * The 1-indexed column number at which this Token begins.
65
- */
70
+ /**
71
+ * The 1-indexed column number at which this Token begins.
72
+ */
66
73
 
67
- /**
68
- * For non-punctuation tokens, represents the interpreted value of the token.
69
- */
74
+ /**
75
+ * For non-punctuation tokens, represents the interpreted value of the token.
76
+ */
70
77
 
71
- /**
72
- * Tokens exist as nodes in a double-linked-list amongst all tokens
73
- * including ignored tokens. <SOF> is always the first node and <EOF>
74
- * the last.
75
- */
76
- function Token(kind, start, end, line, column, prev, value) {
77
- this.kind = kind;
78
- this.start = start;
79
- this.end = end;
80
- this.line = line;
81
- this.column = column;
82
- this.value = value;
83
- this.prev = prev;
84
- this.next = null;
85
- }; // Print a simplified form when appearing in JSON/util.inspect.
86
-
87
- defineToJSON(Token, function () {
88
- return {
89
- kind: this.kind,
90
- value: this.value,
91
- line: this.line,
92
- column: this.column
78
+ /**
79
+ * Tokens exist as nodes in a double-linked-list amongst all tokens
80
+ * including ignored tokens. <SOF> is always the first node and <EOF>
81
+ * the last.
82
+ */
83
+ function Token(kind, start, end, line, column, prev, value) {
84
+ this.kind = kind;
85
+ this.start = start;
86
+ this.end = end;
87
+ this.line = line;
88
+ this.column = column;
89
+ this.value = value;
90
+ this.prev = prev;
91
+ this.next = null;
92
+ }
93
+
94
+ var _proto2 = Token.prototype;
95
+
96
+ _proto2.toJSON = function toJSON() {
97
+ return {
98
+ kind: this.kind,
99
+ value: this.value,
100
+ line: this.line,
101
+ column: this.column
102
+ };
93
103
  };
94
- });
104
+
105
+ return Token;
106
+ }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
107
+
108
+ defineInspect(Token);
95
109
  /**
96
110
  * @internal
97
111
  */
@@ -95,7 +95,8 @@ function printBlockString(value) {
95
95
  var isSingleLine = value.indexOf('\n') === -1;
96
96
  var hasLeadingSpace = value[0] === ' ' || value[0] === '\t';
97
97
  var hasTrailingQuote = value[value.length - 1] === '"';
98
- var printAsMultipleLines = !isSingleLine || hasTrailingQuote || preferMultipleLines;
98
+ var hasTrailingSlash = value[value.length - 1] === '\\';
99
+ var printAsMultipleLines = !isSingleLine || hasTrailingQuote || hasTrailingSlash || preferMultipleLines;
99
100
  var result = ''; // Format a multi-line block quote to account for leading space.
100
101
 
101
102
  if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) {
@@ -85,8 +85,12 @@ export function printBlockString(
85
85
  const isSingleLine = value.indexOf('\n') === -1;
86
86
  const hasLeadingSpace = value[0] === ' ' || value[0] === '\t';
87
87
  const hasTrailingQuote = value[value.length - 1] === '"';
88
+ const hasTrailingSlash = value[value.length - 1] === '\\';
88
89
  const printAsMultipleLines =
89
- !isSingleLine || hasTrailingQuote || preferMultipleLines;
90
+ !isSingleLine ||
91
+ hasTrailingQuote ||
92
+ hasTrailingSlash ||
93
+ preferMultipleLines;
90
94
 
91
95
  let result = '';
92
96
  // Format a multi-line block quote to account for leading space.
@@ -85,7 +85,8 @@ export function printBlockString(value) {
85
85
  var isSingleLine = value.indexOf('\n') === -1;
86
86
  var hasLeadingSpace = value[0] === ' ' || value[0] === '\t';
87
87
  var hasTrailingQuote = value[value.length - 1] === '"';
88
- var printAsMultipleLines = !isSingleLine || hasTrailingQuote || preferMultipleLines;
88
+ var hasTrailingSlash = value[value.length - 1] === '\\';
89
+ var printAsMultipleLines = !isSingleLine || hasTrailingQuote || hasTrailingSlash || preferMultipleLines;
89
90
  var result = ''; // Format a multi-line block quote to account for leading space.
90
91
 
91
92
  if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) {
@@ -1,12 +1,7 @@
1
1
  /**
2
2
  * The set of allowed directive location values.
3
3
  */
4
- export const DirectiveLocation: _DirectiveLocation;
5
-
6
- /**
7
- * @internal
8
- */
9
- type _DirectiveLocation = {
4
+ export const DirectiveLocation: {
10
5
  // Request Definitions
11
6
  QUERY: 'QUERY';
12
7
  MUTATION: 'MUTATION';
@@ -34,4 +29,4 @@ type _DirectiveLocation = {
34
29
  /**
35
30
  * The enum type representing the directive location values.
36
31
  */
37
- export type DirectiveLocationEnum = _DirectiveLocation[keyof _DirectiveLocation];
32
+ export type DirectiveLocationEnum = typeof DirectiveLocation[keyof typeof DirectiveLocation];
package/language/index.js CHANGED
@@ -93,6 +93,18 @@ Object.defineProperty(exports, "BREAK", {
93
93
  return _visitor.BREAK;
94
94
  }
95
95
  });
96
+ Object.defineProperty(exports, "Location", {
97
+ enumerable: true,
98
+ get: function get() {
99
+ return _ast.Location;
100
+ }
101
+ });
102
+ Object.defineProperty(exports, "Token", {
103
+ enumerable: true,
104
+ get: function get() {
105
+ return _ast.Token;
106
+ }
107
+ });
96
108
  Object.defineProperty(exports, "isDefinitionNode", {
97
109
  enumerable: true,
98
110
  get: function get() {
@@ -172,6 +184,8 @@ var _printer = require("./printer");
172
184
 
173
185
  var _visitor = require("./visitor");
174
186
 
187
+ var _ast = require("./ast");
188
+
175
189
  var _predicates = require("./predicates");
176
190
 
177
191
  var _directiveLocation = require("./directiveLocation");
@@ -23,9 +23,8 @@ export { print } from './printer';
23
23
  export { visit, visitInParallel, getVisitFn, BREAK } from './visitor';
24
24
  export type { ASTVisitor, Visitor, VisitFn, VisitorKeyMap } from './visitor';
25
25
 
26
+ export { Location, Token } from './ast';
26
27
  export type {
27
- Location,
28
- Token,
29
28
  ASTNode,
30
29
  ASTKindToNode,
31
30
  // Each kind of AST node
@@ -7,5 +7,6 @@ export { Lexer } from "./lexer.mjs";
7
7
  export { parse, parseValue, parseType } from "./parser.mjs";
8
8
  export { print } from "./printer.mjs";
9
9
  export { visit, visitInParallel, getVisitFn, BREAK } from "./visitor.mjs";
10
+ export { Location, Token } from "./ast.mjs";
10
11
  export { isDefinitionNode, isExecutableDefinitionNode, isSelectionNode, isValueNode, isTypeNode, isTypeSystemDefinitionNode, isTypeDefinitionNode, isTypeSystemExtensionNode, isTypeExtensionNode } from "./predicates.mjs";
11
12
  export { DirectiveLocation } from "./directiveLocation.mjs";
@@ -1,12 +1,7 @@
1
1
  /**
2
2
  * The set of allowed kind values for AST nodes.
3
3
  */
4
- export const Kind: _Kind;
5
-
6
- /**
7
- * @internal
8
- */
9
- type _Kind = {
4
+ export const Kind: {
10
5
  // Name
11
6
  NAME: 'Name';
12
7
 
@@ -76,4 +71,4 @@ type _Kind = {
76
71
  /**
77
72
  * The enum type representing the possible kind values of AST nodes.
78
73
  */
79
- export type KindEnum = _Kind[keyof _Kind];
74
+ export type KindEnum = typeof Kind[keyof typeof Kind];
@@ -1,5 +1,6 @@
1
1
  import { Token } from './ast';
2
2
  import { Source } from './source';
3
+ import { TokenKindEnum } from './tokenKind';
3
4
 
4
5
  /**
5
6
  * Given a Source object, this returns a Lexer for that source.
@@ -50,3 +51,8 @@ export class Lexer {
50
51
  * @internal
51
52
  */
52
53
  export function isPunctuatorToken(token: Token): boolean;
54
+
55
+ /**
56
+ * @internal
57
+ */
58
+ export function isPunctuatorTokenKind(kind: TokenKindEnum): boolean;
@@ -2,9 +2,7 @@
2
2
  * An exported enum describing the different kinds of tokens that the
3
3
  * lexer emits.
4
4
  */
5
- export const TokenKind: _TokenKind;
6
-
7
- type _TokenKind = {
5
+ export const TokenKind: {
8
6
  SOF: '<SOF>';
9
7
  EOF: '<EOF>';
10
8
  BANG: '!';
@@ -32,4 +30,4 @@ type _TokenKind = {
32
30
  /**
33
31
  * The enum type representing the token kinds values.
34
32
  */
35
- export type TokenKindEnum = _TokenKind[keyof _TokenKind];
33
+ export type TokenKindEnum = typeof TokenKind[keyof typeof TokenKind];
@@ -1,4 +1,4 @@
1
- import Maybe from '../tsutils/Maybe';
1
+ import { Maybe } from '../jsutils/Maybe';
2
2
 
3
3
  import { ASTNode, ASTKindToNode } from './ast';
4
4
 
@@ -31,7 +31,7 @@ type ShapeMapVisitor<KindToNode, Nodes> = {
31
31
  * during the visitor's traversal.
32
32
  */
33
33
  export type VisitFn<TAnyNode, TVisitedNode = TAnyNode> = (
34
- /** The current node being visiting.*/
34
+ /** The current node being visiting. */
35
35
  node: TVisitedNode,
36
36
  /** The index or key to this node from the parent node or Array. */
37
37
  key: string | number | undefined,
@@ -39,7 +39,8 @@ export type VisitFn<TAnyNode, TVisitedNode = TAnyNode> = (
39
39
  parent: TAnyNode | ReadonlyArray<TAnyNode> | undefined,
40
40
  /** The key path to get to this node from the root node. */
41
41
  path: ReadonlyArray<string | number>,
42
- /** All nodes and Arrays visited before reaching parent of this node.
42
+ /**
43
+ * All nodes and Arrays visited before reaching parent of this node.
43
44
  * These correspond to array indices in `path`.
44
45
  * Note: ancestors includes arrays which contain the parent of visited node.
45
46
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql",
3
- "version": "15.0.0",
3
+ "version": "15.1.0",
4
4
  "description": "A Query Language and Runtime which can target any service.",
5
5
  "license": "MIT",
6
6
  "main": "index",
@@ -23,4 +23,4 @@
23
23
  "node": ">= 10.x"
24
24
  },
25
25
  "dependencies": {}
26
- }
26
+ }