graphql 16.14.2 → 16.15.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/error/GraphQLError.d.ts +5 -1
- package/error/GraphQLError.js +12 -7
- package/error/GraphQLError.mjs +13 -6
- package/error/locatedError.d.ts +6 -4
- package/error/locatedError.js +6 -4
- package/error/locatedError.mjs +6 -4
- package/execution/collectFields.d.ts +1 -0
- package/execution/collectFields.js +9 -0
- package/execution/collectFields.mjs +9 -0
- package/execution/execute.d.ts +9 -10
- package/execution/execute.js +44 -29
- package/execution/execute.mjs +44 -29
- package/execution/mapAsyncIterator.js +12 -11
- package/execution/mapAsyncIterator.mjs +12 -11
- package/execution/subscribe.d.ts +5 -2
- package/execution/subscribe.js +5 -2
- package/execution/subscribe.mjs +5 -2
- package/execution/values.d.ts +43 -21
- package/execution/values.js +52 -24
- package/execution/values.mjs +51 -23
- package/graphql.d.ts +8 -14
- package/graphql.js +16 -15
- package/graphql.mjs +11 -15
- package/jsutils/SetMap.d.ts +14 -0
- package/jsutils/SetMap.js +48 -0
- package/jsutils/SetMap.mjs +39 -0
- package/jsutils/isIterableObject.d.ts +2 -0
- package/jsutils/isIterableObject.js +2 -0
- package/jsutils/isIterableObject.mjs +2 -0
- package/jsutils/keyMap.d.ts +2 -0
- package/jsutils/keyMap.js +2 -0
- package/jsutils/keyMap.mjs +2 -0
- package/jsutils/keyValMap.d.ts +3 -3
- package/jsutils/keyValMap.js +3 -3
- package/jsutils/keyValMap.mjs +3 -3
- package/language/ast.d.ts +2 -6
- package/language/ast.js +2 -6
- package/language/ast.mjs +2 -6
- package/language/lexer.d.ts +6 -0
- package/language/lexer.js +22 -0
- package/language/lexer.mjs +22 -0
- package/language/location.d.ts +8 -3
- package/language/location.js +57 -17
- package/language/location.mjs +56 -16
- package/language/parser.d.ts +27 -13
- package/language/parser.js +31 -9
- package/language/parser.mjs +31 -9
- package/language/predicates.d.ts +10 -3
- package/language/predicates.js +10 -3
- package/language/predicates.mjs +10 -3
- package/language/printLocation.d.ts +2 -6
- package/language/printLocation.js +2 -6
- package/language/printLocation.mjs +2 -6
- package/language/printer.d.ts +22 -3
- package/language/printer.js +394 -308
- package/language/printer.mjs +394 -308
- package/language/reducer.d.ts +32 -0
- package/language/reducer.js +95 -0
- package/language/reducer.mjs +86 -0
- package/language/source.d.ts +4 -5
- package/language/source.js +4 -5
- package/language/source.mjs +4 -5
- package/language/visitor.d.ts +16 -10
- package/language/visitor.js +15 -7
- package/language/visitor.mjs +15 -7
- package/package.json +1 -4
- package/type/definition.d.ts +170 -102
- package/type/definition.js +169 -96
- package/type/definition.mjs +168 -95
- package/type/directives.d.ts +12 -6
- package/type/directives.js +12 -6
- package/type/directives.mjs +12 -6
- package/type/scalars.js +8 -11
- package/type/scalars.mjs +1 -1
- package/type/schema.d.ts +36 -11
- package/type/schema.js +35 -10
- package/type/schema.mjs +35 -10
- package/type/validate.d.ts +1 -3
- package/type/validate.js +1 -3
- package/type/validate.mjs +1 -3
- package/utilities/TypeInfo.d.ts +15 -11
- package/utilities/TypeInfo.js +15 -11
- package/utilities/TypeInfo.mjs +15 -11
- package/utilities/assertValidName.d.ts +1 -1
- package/utilities/assertValidName.js +1 -1
- package/utilities/assertValidName.mjs +1 -1
- package/utilities/astFromValue.d.ts +3 -1
- package/utilities/astFromValue.js +3 -1
- package/utilities/astFromValue.mjs +3 -1
- package/utilities/buildASTSchema.d.ts +8 -8
- package/utilities/buildASTSchema.js +9 -20
- package/utilities/buildASTSchema.mjs +9 -20
- package/utilities/buildClientSchema.d.ts +6 -2
- package/utilities/buildClientSchema.js +6 -2
- package/utilities/buildClientSchema.mjs +6 -2
- package/utilities/coerceInputValue.d.ts +9 -3
- package/utilities/coerceInputValue.js +60 -13
- package/utilities/coerceInputValue.mjs +58 -13
- package/utilities/concatAST.d.ts +4 -1
- package/utilities/concatAST.js +4 -1
- package/utilities/concatAST.mjs +4 -1
- package/utilities/extendSchema.d.ts +7 -4
- package/utilities/extendSchema.js +7 -4
- package/utilities/extendSchema.mjs +7 -4
- package/utilities/findBreakingChanges.d.ts +2 -2
- package/utilities/findBreakingChanges.js +2 -2
- package/utilities/findBreakingChanges.mjs +2 -2
- package/utilities/getIntrospectionQuery.d.ts +9 -9
- package/utilities/getIntrospectionQuery.js +8 -8
- package/utilities/getIntrospectionQuery.mjs +8 -8
- package/utilities/getOperationAST.d.ts +2 -2
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.mjs +2 -2
- package/utilities/getOperationRootType.d.ts +3 -1
- package/utilities/getOperationRootType.js +3 -1
- package/utilities/getOperationRootType.mjs +3 -1
- package/utilities/introspectionFromSchema.d.ts +12 -4
- package/utilities/introspectionFromSchema.js +12 -4
- package/utilities/introspectionFromSchema.mjs +12 -4
- package/utilities/lexicographicSortSchema.d.ts +17 -13
- package/utilities/lexicographicSortSchema.js +17 -13
- package/utilities/lexicographicSortSchema.mjs +17 -13
- package/utilities/printSchema.d.ts +7 -4
- package/utilities/printSchema.js +7 -4
- package/utilities/printSchema.mjs +7 -4
- package/utilities/resolveSchemaCoordinate.d.ts +9 -8
- package/utilities/resolveSchemaCoordinate.js +9 -8
- package/utilities/resolveSchemaCoordinate.mjs +9 -8
- package/utilities/separateOperations.d.ts +2 -2
- package/utilities/separateOperations.js +2 -2
- package/utilities/separateOperations.mjs +2 -2
- package/utilities/stripIgnoredCharacters.d.ts +19 -5
- package/utilities/stripIgnoredCharacters.js +19 -5
- package/utilities/stripIgnoredCharacters.mjs +19 -5
- package/utilities/typeComparators.d.ts +1 -5
- package/utilities/typeComparators.js +1 -5
- package/utilities/typeComparators.mjs +1 -5
- package/utilities/valueFromAST.js +4 -4
- package/utilities/valueFromAST.mjs +4 -4
- package/utilities/valueFromASTUntyped.d.ts +1 -3
- package/utilities/valueFromASTUntyped.js +1 -3
- package/utilities/valueFromASTUntyped.mjs +1 -3
- package/validation/ValidationContext.d.ts +22 -3
- package/validation/ValidationContext.js +84 -27
- package/validation/ValidationContext.mjs +82 -27
- package/validation/rules/ExecutableDefinitionsRule.d.ts +6 -4
- package/validation/rules/ExecutableDefinitionsRule.js +6 -4
- package/validation/rules/ExecutableDefinitionsRule.mjs +6 -4
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +4 -4
- package/validation/rules/FieldsOnCorrectTypeRule.js +10 -6
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +12 -6
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +6 -4
- package/validation/rules/FragmentsOnCompositeTypesRule.js +6 -4
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs +6 -4
- package/validation/rules/KnownArgumentNamesRule.d.ts +4 -4
- package/validation/rules/KnownArgumentNamesRule.js +26 -17
- package/validation/rules/KnownArgumentNamesRule.mjs +21 -11
- package/validation/rules/KnownDirectivesRule.d.ts +1 -3
- package/validation/rules/KnownDirectivesRule.js +1 -3
- package/validation/rules/KnownDirectivesRule.mjs +1 -3
- package/validation/rules/KnownFragmentNamesRule.d.ts +4 -4
- package/validation/rules/KnownFragmentNamesRule.js +4 -4
- package/validation/rules/KnownFragmentNamesRule.mjs +4 -4
- package/validation/rules/KnownTypeNamesRule.d.ts +1 -3
- package/validation/rules/KnownTypeNamesRule.js +7 -7
- package/validation/rules/KnownTypeNamesRule.mjs +7 -7
- package/validation/rules/LoneAnonymousOperationRule.d.ts +6 -4
- package/validation/rules/LoneAnonymousOperationRule.js +6 -4
- package/validation/rules/LoneAnonymousOperationRule.mjs +6 -4
- package/validation/rules/MaxIntrospectionDepthRule.d.ts +6 -4
- package/validation/rules/MaxIntrospectionDepthRule.js +44 -19
- package/validation/rules/MaxIntrospectionDepthRule.mjs +44 -19
- package/validation/rules/NoFragmentCyclesRule.d.ts +1 -3
- package/validation/rules/NoFragmentCyclesRule.js +1 -3
- package/validation/rules/NoFragmentCyclesRule.mjs +1 -3
- package/validation/rules/NoUndefinedVariablesRule.d.ts +4 -4
- package/validation/rules/NoUndefinedVariablesRule.js +4 -4
- package/validation/rules/NoUndefinedVariablesRule.mjs +4 -4
- package/validation/rules/NoUnusedFragmentsRule.d.ts +4 -4
- package/validation/rules/NoUnusedFragmentsRule.js +10 -14
- package/validation/rules/NoUnusedFragmentsRule.mjs +10 -14
- package/validation/rules/NoUnusedVariablesRule.d.ts +4 -4
- package/validation/rules/NoUnusedVariablesRule.js +4 -4
- package/validation/rules/NoUnusedVariablesRule.mjs +4 -4
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +8 -6
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +552 -354
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +545 -352
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +6 -4
- package/validation/rules/PossibleFragmentSpreadsRule.js +6 -4
- package/validation/rules/PossibleFragmentSpreadsRule.mjs +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.js +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs +6 -4
- package/validation/rules/ScalarLeafsRule.d.ts +1 -3
- package/validation/rules/ScalarLeafsRule.js +1 -3
- package/validation/rules/ScalarLeafsRule.mjs +1 -3
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +6 -4
- package/validation/rules/SingleFieldSubscriptionsRule.js +50 -9
- package/validation/rules/SingleFieldSubscriptionsRule.mjs +50 -9
- package/validation/rules/UniqueArgumentNamesRule.d.ts +4 -4
- package/validation/rules/UniqueArgumentNamesRule.js +4 -4
- package/validation/rules/UniqueArgumentNamesRule.mjs +4 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +6 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.js +6 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +6 -4
- package/validation/rules/UniqueFragmentNamesRule.d.ts +4 -4
- package/validation/rules/UniqueFragmentNamesRule.js +4 -4
- package/validation/rules/UniqueFragmentNamesRule.mjs +4 -4
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +6 -4
- package/validation/rules/UniqueInputFieldNamesRule.js +6 -4
- package/validation/rules/UniqueInputFieldNamesRule.mjs +6 -4
- package/validation/rules/UniqueOperationNamesRule.d.ts +4 -4
- package/validation/rules/UniqueOperationNamesRule.js +4 -4
- package/validation/rules/UniqueOperationNamesRule.mjs +4 -4
- package/validation/rules/UniqueVariableNamesRule.d.ts +4 -4
- package/validation/rules/UniqueVariableNamesRule.js +4 -4
- package/validation/rules/UniqueVariableNamesRule.mjs +4 -4
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +4 -4
- package/validation/rules/ValuesOfCorrectTypeRule.js +29 -23
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +24 -14
- package/validation/rules/VariablesAreInputTypesRule.d.ts +6 -4
- package/validation/rules/VariablesAreInputTypesRule.js +6 -4
- package/validation/rules/VariablesAreInputTypesRule.mjs +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.js +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.mjs +6 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +4 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.js +4 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +4 -4
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +7 -5
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +7 -5
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +7 -5
- package/validation/validate.d.ts +2 -0
- package/validation/validate.js +14 -2
- package/validation/validate.mjs +13 -2
- package/validation/validationAbortedError.d.ts +3 -0
- package/validation/validationAbortedError.js +14 -0
- package/validation/validationAbortedError.mjs +4 -0
- package/version.js +3 -3
- package/version.mjs +3 -3
package/graphql.js
CHANGED
|
@@ -45,13 +45,11 @@ var _execute = require('./execution/execute.js');
|
|
|
45
45
|
* schema,
|
|
46
46
|
* source: 'query SayHello($name: String!) { greeting(name: $name) }',
|
|
47
47
|
* rootValue: {
|
|
48
|
-
* greeting: ({ name }) => `Hello, ${name}!`,
|
|
48
|
+
* greeting: ({ name }: { name: string }) => `Hello, ${name}!`,
|
|
49
49
|
* },
|
|
50
50
|
* variableValues: { name: 'Ada' },
|
|
51
51
|
* operationName: 'SayHello',
|
|
52
|
-
* });
|
|
53
|
-
*
|
|
54
|
-
* result; // => { data: { greeting: 'Hello, Ada!' } }
|
|
52
|
+
* }); // => { data: { greeting: 'Hello, Ada!' } }
|
|
55
53
|
* ```
|
|
56
54
|
* @example
|
|
57
55
|
* ```ts
|
|
@@ -84,9 +82,7 @@ var _execute = require('./execution/execute.js');
|
|
|
84
82
|
* typeResolver: (value) => {
|
|
85
83
|
* return value.kind === 'user' ? 'User' : undefined;
|
|
86
84
|
* },
|
|
87
|
-
* });
|
|
88
|
-
*
|
|
89
|
-
* result; // => { data: { viewer: { __typename: 'User', name: 'Ada' } } }
|
|
85
|
+
* }); // => { data: { viewer: { __typename: 'User', name: 'Ada' } } }
|
|
90
86
|
* ```
|
|
91
87
|
* @category Request Pipeline
|
|
92
88
|
*/
|
|
@@ -118,13 +114,11 @@ function graphql(args) {
|
|
|
118
114
|
* schema,
|
|
119
115
|
* source: 'query SayHello($name: String!) { greeting(name: $name) }',
|
|
120
116
|
* rootValue: {
|
|
121
|
-
* greeting: ({ name }) => `Hello, ${name}!`,
|
|
117
|
+
* greeting: ({ name }: { name: string }) => `Hello, ${name}!`,
|
|
122
118
|
* },
|
|
123
119
|
* variableValues: { name: 'Ada' },
|
|
124
120
|
* operationName: 'SayHello',
|
|
125
|
-
* });
|
|
126
|
-
*
|
|
127
|
-
* result; // => { data: { greeting: 'Hello, Ada!' } }
|
|
121
|
+
* }); // => { data: { greeting: 'Hello, Ada!' } }
|
|
128
122
|
* ```
|
|
129
123
|
* @example
|
|
130
124
|
* ```ts
|
|
@@ -144,9 +138,7 @@ function graphql(args) {
|
|
|
144
138
|
* return contextValue.defaultGreeting;
|
|
145
139
|
* },
|
|
146
140
|
* contextValue: { defaultGreeting: 'Hello' },
|
|
147
|
-
* });
|
|
148
|
-
*
|
|
149
|
-
* result; // => { data: { greeting: 'Hello' } }
|
|
141
|
+
* }); // => { data: { greeting: 'Hello' } }
|
|
150
142
|
* ```
|
|
151
143
|
* @category Request Pipeline
|
|
152
144
|
*/
|
|
@@ -177,6 +169,7 @@ function graphqlImpl(args) {
|
|
|
177
169
|
operationName,
|
|
178
170
|
fieldResolver,
|
|
179
171
|
typeResolver,
|
|
172
|
+
hideSuggestions,
|
|
180
173
|
} = args; // Validate Schema
|
|
181
174
|
|
|
182
175
|
const schemaValidationErrors = (0, _validate.validateSchema)(schema);
|
|
@@ -197,7 +190,14 @@ function graphqlImpl(args) {
|
|
|
197
190
|
};
|
|
198
191
|
} // Validate
|
|
199
192
|
|
|
200
|
-
const validationErrors = (0, _validate2.validate)(
|
|
193
|
+
const validationErrors = (0, _validate2.validate)(
|
|
194
|
+
schema,
|
|
195
|
+
document,
|
|
196
|
+
undefined,
|
|
197
|
+
{
|
|
198
|
+
hideSuggestions,
|
|
199
|
+
},
|
|
200
|
+
);
|
|
201
201
|
|
|
202
202
|
if (validationErrors.length > 0) {
|
|
203
203
|
return {
|
|
@@ -214,5 +214,6 @@ function graphqlImpl(args) {
|
|
|
214
214
|
operationName,
|
|
215
215
|
fieldResolver,
|
|
216
216
|
typeResolver,
|
|
217
|
+
hideSuggestions,
|
|
217
218
|
});
|
|
218
219
|
}
|
package/graphql.mjs
CHANGED
|
@@ -39,13 +39,11 @@ import { execute } from './execution/execute.mjs';
|
|
|
39
39
|
* schema,
|
|
40
40
|
* source: 'query SayHello($name: String!) { greeting(name: $name) }',
|
|
41
41
|
* rootValue: {
|
|
42
|
-
* greeting: ({ name }) => `Hello, ${name}!`,
|
|
42
|
+
* greeting: ({ name }: { name: string }) => `Hello, ${name}!`,
|
|
43
43
|
* },
|
|
44
44
|
* variableValues: { name: 'Ada' },
|
|
45
45
|
* operationName: 'SayHello',
|
|
46
|
-
* });
|
|
47
|
-
*
|
|
48
|
-
* result; // => { data: { greeting: 'Hello, Ada!' } }
|
|
46
|
+
* }); // => { data: { greeting: 'Hello, Ada!' } }
|
|
49
47
|
* ```
|
|
50
48
|
* @example
|
|
51
49
|
* ```ts
|
|
@@ -78,9 +76,7 @@ import { execute } from './execution/execute.mjs';
|
|
|
78
76
|
* typeResolver: (value) => {
|
|
79
77
|
* return value.kind === 'user' ? 'User' : undefined;
|
|
80
78
|
* },
|
|
81
|
-
* });
|
|
82
|
-
*
|
|
83
|
-
* result; // => { data: { viewer: { __typename: 'User', name: 'Ada' } } }
|
|
79
|
+
* }); // => { data: { viewer: { __typename: 'User', name: 'Ada' } } }
|
|
84
80
|
* ```
|
|
85
81
|
* @category Request Pipeline
|
|
86
82
|
*/
|
|
@@ -112,13 +108,11 @@ export function graphql(args) {
|
|
|
112
108
|
* schema,
|
|
113
109
|
* source: 'query SayHello($name: String!) { greeting(name: $name) }',
|
|
114
110
|
* rootValue: {
|
|
115
|
-
* greeting: ({ name }) => `Hello, ${name}!`,
|
|
111
|
+
* greeting: ({ name }: { name: string }) => `Hello, ${name}!`,
|
|
116
112
|
* },
|
|
117
113
|
* variableValues: { name: 'Ada' },
|
|
118
114
|
* operationName: 'SayHello',
|
|
119
|
-
* });
|
|
120
|
-
*
|
|
121
|
-
* result; // => { data: { greeting: 'Hello, Ada!' } }
|
|
115
|
+
* }); // => { data: { greeting: 'Hello, Ada!' } }
|
|
122
116
|
* ```
|
|
123
117
|
* @example
|
|
124
118
|
* ```ts
|
|
@@ -138,9 +132,7 @@ export function graphql(args) {
|
|
|
138
132
|
* return contextValue.defaultGreeting;
|
|
139
133
|
* },
|
|
140
134
|
* contextValue: { defaultGreeting: 'Hello' },
|
|
141
|
-
* });
|
|
142
|
-
*
|
|
143
|
-
* result; // => { data: { greeting: 'Hello' } }
|
|
135
|
+
* }); // => { data: { greeting: 'Hello' } }
|
|
144
136
|
* ```
|
|
145
137
|
* @category Request Pipeline
|
|
146
138
|
*/
|
|
@@ -171,6 +163,7 @@ function graphqlImpl(args) {
|
|
|
171
163
|
operationName,
|
|
172
164
|
fieldResolver,
|
|
173
165
|
typeResolver,
|
|
166
|
+
hideSuggestions,
|
|
174
167
|
} = args; // Validate Schema
|
|
175
168
|
|
|
176
169
|
const schemaValidationErrors = validateSchema(schema);
|
|
@@ -191,7 +184,9 @@ function graphqlImpl(args) {
|
|
|
191
184
|
};
|
|
192
185
|
} // Validate
|
|
193
186
|
|
|
194
|
-
const validationErrors = validate(schema, document
|
|
187
|
+
const validationErrors = validate(schema, document, undefined, {
|
|
188
|
+
hideSuggestions,
|
|
189
|
+
});
|
|
195
190
|
|
|
196
191
|
if (validationErrors.length > 0) {
|
|
197
192
|
return {
|
|
@@ -208,5 +203,6 @@ function graphqlImpl(args) {
|
|
|
208
203
|
operationName,
|
|
209
204
|
fieldResolver,
|
|
210
205
|
typeResolver,
|
|
206
|
+
hideSuggestions,
|
|
211
207
|
});
|
|
212
208
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps an order-independent set of member identities to a value.
|
|
3
|
+
* Each member receives a map-local ID; sorted IDs form the exact key.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare class SetMap<T, V> {
|
|
7
|
+
_entries: Map<string, V>;
|
|
8
|
+
_memberIds: Map<T, number>;
|
|
9
|
+
_nextMemberId: number;
|
|
10
|
+
constructor();
|
|
11
|
+
get(members: ReadonlySet<T>): V | undefined;
|
|
12
|
+
set(members: ReadonlySet<T>, value: V): void;
|
|
13
|
+
_key(members: ReadonlySet<T>): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.SetMap = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Maps an order-independent set of member identities to a value.
|
|
10
|
+
* Each member receives a map-local ID; sorted IDs form the exact key.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
class SetMap {
|
|
14
|
+
constructor() {
|
|
15
|
+
this._entries = new Map();
|
|
16
|
+
this._memberIds = new Map();
|
|
17
|
+
this._nextMemberId = 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get(members) {
|
|
21
|
+
return this._entries.get(this._key(members));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
set(members, value) {
|
|
25
|
+
this._entries.set(this._key(members), value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_key(members) {
|
|
29
|
+
const ids = [];
|
|
30
|
+
|
|
31
|
+
for (const member of members) {
|
|
32
|
+
let id = this._memberIds.get(member);
|
|
33
|
+
|
|
34
|
+
if (id === undefined) {
|
|
35
|
+
id = this._nextMemberId++;
|
|
36
|
+
|
|
37
|
+
this._memberIds.set(member, id);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ids.push(id);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
ids.sort((id1, id2) => id1 - id2);
|
|
44
|
+
return ids.join(',');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
exports.SetMap = SetMap;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps an order-independent set of member identities to a value.
|
|
3
|
+
* Each member receives a map-local ID; sorted IDs form the exact key.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export class SetMap {
|
|
7
|
+
constructor() {
|
|
8
|
+
this._entries = new Map();
|
|
9
|
+
this._memberIds = new Map();
|
|
10
|
+
this._nextMemberId = 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get(members) {
|
|
14
|
+
return this._entries.get(this._key(members));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
set(members, value) {
|
|
18
|
+
this._entries.set(this._key(members), value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
_key(members) {
|
|
22
|
+
const ids = [];
|
|
23
|
+
|
|
24
|
+
for (const member of members) {
|
|
25
|
+
let id = this._memberIds.get(member);
|
|
26
|
+
|
|
27
|
+
if (id === undefined) {
|
|
28
|
+
id = this._nextMemberId++;
|
|
29
|
+
|
|
30
|
+
this._memberIds.set(member, id);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
ids.push(id);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
ids.sort((id1, id2) => id1 - id2);
|
|
37
|
+
return ids.join(',');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -16,6 +16,8 @@ exports.isIterableObject = isIterableObject;
|
|
|
16
16
|
* @internal
|
|
17
17
|
* @example
|
|
18
18
|
* ```ts
|
|
19
|
+
* import { isIterableObject } from 'graphql/jsutils/isIterableObject';
|
|
20
|
+
*
|
|
19
21
|
* isIterableObject([1, 2, 3]); // => true
|
|
20
22
|
* isIterableObject(new Map()); // => true
|
|
21
23
|
* isIterableObject('ABC'); // => false
|
package/jsutils/keyMap.d.ts
CHANGED
package/jsutils/keyMap.js
CHANGED
package/jsutils/keyMap.mjs
CHANGED
package/jsutils/keyValMap.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type { ObjMap } from './ObjMap';
|
|
|
5
5
|
* @internal
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
|
+
* import { keyValMap } from 'graphql/jsutils/keyValMap';
|
|
9
|
+
*
|
|
8
10
|
* const phoneBook = [
|
|
9
11
|
* { name: 'Jon', num: '555-1234' },
|
|
10
12
|
* { name: 'Jenny', num: '867-5309' },
|
|
@@ -14,9 +16,7 @@ import type { ObjMap } from './ObjMap';
|
|
|
14
16
|
* phoneBook,
|
|
15
17
|
* (entry) => entry.name,
|
|
16
18
|
* (entry) => entry.num,
|
|
17
|
-
* );
|
|
18
|
-
*
|
|
19
|
-
* phonesByName; // => { Jon: '555-1234', Jenny: '867-5309' }
|
|
19
|
+
* ); // => { Jon: '555-1234', Jenny: '867-5309' }
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export declare function keyValMap<T, V>(
|
package/jsutils/keyValMap.js
CHANGED
|
@@ -11,6 +11,8 @@ exports.keyValMap = keyValMap;
|
|
|
11
11
|
* @internal
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts
|
|
14
|
+
* import { keyValMap } from 'graphql/jsutils/keyValMap';
|
|
15
|
+
*
|
|
14
16
|
* const phoneBook = [
|
|
15
17
|
* { name: 'Jon', num: '555-1234' },
|
|
16
18
|
* { name: 'Jenny', num: '867-5309' },
|
|
@@ -20,9 +22,7 @@ exports.keyValMap = keyValMap;
|
|
|
20
22
|
* phoneBook,
|
|
21
23
|
* (entry) => entry.name,
|
|
22
24
|
* (entry) => entry.num,
|
|
23
|
-
* );
|
|
24
|
-
*
|
|
25
|
-
* phonesByName; // => { Jon: '555-1234', Jenny: '867-5309' }
|
|
25
|
+
* ); // => { Jon: '555-1234', Jenny: '867-5309' }
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
function keyValMap(list, keyFn, valFn) {
|
package/jsutils/keyValMap.mjs
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* @internal
|
|
5
5
|
* @example
|
|
6
6
|
* ```ts
|
|
7
|
+
* import { keyValMap } from 'graphql/jsutils/keyValMap';
|
|
8
|
+
*
|
|
7
9
|
* const phoneBook = [
|
|
8
10
|
* { name: 'Jon', num: '555-1234' },
|
|
9
11
|
* { name: 'Jenny', num: '867-5309' },
|
|
@@ -13,9 +15,7 @@
|
|
|
13
15
|
* phoneBook,
|
|
14
16
|
* (entry) => entry.name,
|
|
15
17
|
* (entry) => entry.num,
|
|
16
|
-
* );
|
|
17
|
-
*
|
|
18
|
-
* phonesByName; // => { Jon: '555-1234', Jenny: '867-5309' }
|
|
18
|
+
* ); // => { Jon: '555-1234', Jenny: '867-5309' }
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
export function keyValMap(list, keyFn, valFn) {
|
package/language/ast.d.ts
CHANGED
|
@@ -50,9 +50,7 @@ export declare class Location {
|
|
|
50
50
|
* import { parse } from 'graphql/language';
|
|
51
51
|
*
|
|
52
52
|
* const document = parse('{ hello }');
|
|
53
|
-
* const location = document.loc?.toJSON();
|
|
54
|
-
*
|
|
55
|
-
* location; // => { start: 0, end: 9 }
|
|
53
|
+
* const location = document.loc?.toJSON(); // => { start: 0, end: 9 }
|
|
56
54
|
* ```
|
|
57
55
|
*/
|
|
58
56
|
toJSON(): {
|
|
@@ -130,9 +128,7 @@ export declare class Token {
|
|
|
130
128
|
* import { Lexer, Source } from 'graphql/language';
|
|
131
129
|
*
|
|
132
130
|
* const lexer = new Lexer(new Source('{ hello }'));
|
|
133
|
-
* const token = lexer.advance().toJSON();
|
|
134
|
-
*
|
|
135
|
-
* token; // => { kind: '{', value: undefined, line: 1, column: 1 }
|
|
131
|
+
* const token = lexer.advance().toJSON(); // => { kind: '{', value: undefined, line: 1, column: 1 }
|
|
136
132
|
* ```
|
|
137
133
|
*/
|
|
138
134
|
toJSON(): {
|
package/language/ast.js
CHANGED
|
@@ -69,9 +69,7 @@ class Location {
|
|
|
69
69
|
* import { parse } from 'graphql/language';
|
|
70
70
|
*
|
|
71
71
|
* const document = parse('{ hello }');
|
|
72
|
-
* const location = document.loc?.toJSON();
|
|
73
|
-
*
|
|
74
|
-
* location; // => { start: 0, end: 9 }
|
|
72
|
+
* const location = document.loc?.toJSON(); // => { start: 0, end: 9 }
|
|
75
73
|
* ```
|
|
76
74
|
*/
|
|
77
75
|
|
|
@@ -161,9 +159,7 @@ class Token {
|
|
|
161
159
|
* import { Lexer, Source } from 'graphql/language';
|
|
162
160
|
*
|
|
163
161
|
* const lexer = new Lexer(new Source('{ hello }'));
|
|
164
|
-
* const token = lexer.advance().toJSON();
|
|
165
|
-
*
|
|
166
|
-
* token; // => { kind: '{', value: undefined, line: 1, column: 1 }
|
|
162
|
+
* const token = lexer.advance().toJSON(); // => { kind: '{', value: undefined, line: 1, column: 1 }
|
|
167
163
|
* ```
|
|
168
164
|
*/
|
|
169
165
|
|
package/language/ast.mjs
CHANGED
|
@@ -57,9 +57,7 @@ export class Location {
|
|
|
57
57
|
* import { parse } from 'graphql/language';
|
|
58
58
|
*
|
|
59
59
|
* const document = parse('{ hello }');
|
|
60
|
-
* const location = document.loc?.toJSON();
|
|
61
|
-
*
|
|
62
|
-
* location; // => { start: 0, end: 9 }
|
|
60
|
+
* const location = document.loc?.toJSON(); // => { start: 0, end: 9 }
|
|
63
61
|
* ```
|
|
64
62
|
*/
|
|
65
63
|
|
|
@@ -147,9 +145,7 @@ export class Token {
|
|
|
147
145
|
* import { Lexer, Source } from 'graphql/language';
|
|
148
146
|
*
|
|
149
147
|
* const lexer = new Lexer(new Source('{ hello }'));
|
|
150
|
-
* const token = lexer.advance().toJSON();
|
|
151
|
-
*
|
|
152
|
-
* token; // => { kind: '{', value: undefined, line: 1, column: 1 }
|
|
148
|
+
* const token = lexer.advance().toJSON(); // => { kind: '{', value: undefined, line: 1, column: 1 }
|
|
153
149
|
* ```
|
|
154
150
|
*/
|
|
155
151
|
|
package/language/lexer.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export interface LexerInterface {
|
|
|
14
14
|
token: Token;
|
|
15
15
|
line: number;
|
|
16
16
|
lineStart: number;
|
|
17
|
+
_maxComments?: number | undefined;
|
|
18
|
+
_commentCount?: number | undefined;
|
|
17
19
|
advance: () => Token;
|
|
18
20
|
lookahead: () => Token;
|
|
19
21
|
}
|
|
@@ -36,6 +38,10 @@ export declare class Lexer implements LexerInterface {
|
|
|
36
38
|
line: number;
|
|
37
39
|
/** Character offset where the current line starts. */
|
|
38
40
|
lineStart: number;
|
|
41
|
+
/** @internal */
|
|
42
|
+
_maxComments: number | undefined;
|
|
43
|
+
/** @internal */
|
|
44
|
+
_commentCount: number;
|
|
39
45
|
/**
|
|
40
46
|
* Creates a Lexer instance.
|
|
41
47
|
* @param source - Source document used to derive error locations.
|
package/language/lexer.js
CHANGED
|
@@ -40,6 +40,10 @@ class Lexer {
|
|
|
40
40
|
|
|
41
41
|
/** Character offset where the current line starts. */
|
|
42
42
|
|
|
43
|
+
/** @internal */
|
|
44
|
+
|
|
45
|
+
/** @internal */
|
|
46
|
+
|
|
43
47
|
/**
|
|
44
48
|
* Creates a Lexer instance.
|
|
45
49
|
* @param source - Source document used to derive error locations.
|
|
@@ -68,6 +72,8 @@ class Lexer {
|
|
|
68
72
|
this.token = startOfFileToken;
|
|
69
73
|
this.line = 1;
|
|
70
74
|
this.lineStart = 0;
|
|
75
|
+
this._maxComments = undefined;
|
|
76
|
+
this._commentCount = 0;
|
|
71
77
|
}
|
|
72
78
|
/**
|
|
73
79
|
* Returns the value used by `Object.prototype.toString`.
|
|
@@ -493,6 +499,22 @@ function readNextToken(lexer, start) {
|
|
|
493
499
|
*/
|
|
494
500
|
|
|
495
501
|
function readComment(lexer, start) {
|
|
502
|
+
const maxComments = lexer._maxComments;
|
|
503
|
+
|
|
504
|
+
if (maxComments !== undefined) {
|
|
505
|
+
const nextCommentCount = lexer._commentCount + 1;
|
|
506
|
+
|
|
507
|
+
if (nextCommentCount > maxComments) {
|
|
508
|
+
throw (0, _syntaxError.syntaxError)(
|
|
509
|
+
lexer.source,
|
|
510
|
+
start,
|
|
511
|
+
`Document contains more than ${maxComments} comments. Parsing aborted.`,
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
lexer._commentCount = nextCommentCount;
|
|
516
|
+
}
|
|
517
|
+
|
|
496
518
|
const body = lexer.source.body;
|
|
497
519
|
const bodyLength = body.length;
|
|
498
520
|
let position = start + 1;
|
package/language/lexer.mjs
CHANGED
|
@@ -30,6 +30,10 @@ export class Lexer {
|
|
|
30
30
|
|
|
31
31
|
/** Character offset where the current line starts. */
|
|
32
32
|
|
|
33
|
+
/** @internal */
|
|
34
|
+
|
|
35
|
+
/** @internal */
|
|
36
|
+
|
|
33
37
|
/**
|
|
34
38
|
* Creates a Lexer instance.
|
|
35
39
|
* @param source - Source document used to derive error locations.
|
|
@@ -52,6 +56,8 @@ export class Lexer {
|
|
|
52
56
|
this.token = startOfFileToken;
|
|
53
57
|
this.line = 1;
|
|
54
58
|
this.lineStart = 0;
|
|
59
|
+
this._maxComments = undefined;
|
|
60
|
+
this._commentCount = 0;
|
|
55
61
|
}
|
|
56
62
|
/**
|
|
57
63
|
* Returns the value used by `Object.prototype.toString`.
|
|
@@ -405,6 +411,22 @@ function readNextToken(lexer, start) {
|
|
|
405
411
|
*/
|
|
406
412
|
|
|
407
413
|
function readComment(lexer, start) {
|
|
414
|
+
const maxComments = lexer._maxComments;
|
|
415
|
+
|
|
416
|
+
if (maxComments !== undefined) {
|
|
417
|
+
const nextCommentCount = lexer._commentCount + 1;
|
|
418
|
+
|
|
419
|
+
if (nextCommentCount > maxComments) {
|
|
420
|
+
throw syntaxError(
|
|
421
|
+
lexer.source,
|
|
422
|
+
start,
|
|
423
|
+
`Document contains more than ${maxComments} comments. Parsing aborted.`,
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
lexer._commentCount = nextCommentCount;
|
|
428
|
+
}
|
|
429
|
+
|
|
408
430
|
const body = lexer.source.body;
|
|
409
431
|
const bodyLength = body.length;
|
|
410
432
|
let position = start + 1;
|
package/language/location.d.ts
CHANGED
|
@@ -18,12 +18,17 @@ export interface SourceLocation {
|
|
|
18
18
|
* import { Source, getLocation } from 'graphql/language';
|
|
19
19
|
*
|
|
20
20
|
* const source = new Source('type Query { hello: String }');
|
|
21
|
-
* const location = getLocation(source, 13);
|
|
22
|
-
*
|
|
23
|
-
* location; // => { line: 1, column: 14 }
|
|
21
|
+
* const location = getLocation(source, 13); // => { line: 1, column: 14 }
|
|
24
22
|
* ```
|
|
25
23
|
*/
|
|
26
24
|
export declare function getLocation(
|
|
27
25
|
source: Source,
|
|
28
26
|
position: number,
|
|
29
27
|
): SourceLocation;
|
|
28
|
+
/** @internal */
|
|
29
|
+
export declare function getLocations(
|
|
30
|
+
locations: ReadonlyArray<{
|
|
31
|
+
source: Source;
|
|
32
|
+
start: number;
|
|
33
|
+
}>,
|
|
34
|
+
): Array<SourceLocation>;
|
package/language/location.js
CHANGED
|
@@ -4,11 +4,10 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
4
4
|
value: true,
|
|
5
5
|
});
|
|
6
6
|
exports.getLocation = getLocation;
|
|
7
|
-
|
|
8
|
-
var _invariant = require('../jsutils/invariant.js');
|
|
7
|
+
exports.getLocations = getLocations;
|
|
9
8
|
|
|
10
9
|
/** @category Source */
|
|
11
|
-
|
|
10
|
+
|
|
12
11
|
/** Represents a location in a Source. */
|
|
13
12
|
|
|
14
13
|
/**
|
|
@@ -22,28 +21,69 @@ const LineRegExp = /\r\n|[\n\r]/g;
|
|
|
22
21
|
* import { Source, getLocation } from 'graphql/language';
|
|
23
22
|
*
|
|
24
23
|
* const source = new Source('type Query { hello: String }');
|
|
25
|
-
* const location = getLocation(source, 13);
|
|
26
|
-
*
|
|
27
|
-
* location; // => { line: 1, column: 14 }
|
|
24
|
+
* const location = getLocation(source, 13); // => { line: 1, column: 14 }
|
|
28
25
|
* ```
|
|
29
26
|
*/
|
|
30
27
|
function getLocation(source, position) {
|
|
31
|
-
|
|
28
|
+
const lineRegexp = /\r\n|[\n\r]/g;
|
|
32
29
|
let line = 1;
|
|
30
|
+
let column = position + 1;
|
|
31
|
+
let match;
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (match.index >= position) {
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
lastLineStart = match.index + match[0].length;
|
|
42
|
-
line += 1;
|
|
33
|
+
while ((match = lineRegexp.exec(source.body)) && match.index < position) {
|
|
34
|
+
line++;
|
|
35
|
+
column = position + 1 - (match.index + match[0].length);
|
|
43
36
|
}
|
|
44
37
|
|
|
45
38
|
return {
|
|
46
39
|
line,
|
|
47
|
-
column
|
|
40
|
+
column,
|
|
48
41
|
};
|
|
49
42
|
}
|
|
43
|
+
/** @internal */
|
|
44
|
+
|
|
45
|
+
function getLocations(locations) {
|
|
46
|
+
if (locations.length < 2) {
|
|
47
|
+
return locations.map(({ source, start }) => getLocation(source, start));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const bySource = new Map();
|
|
51
|
+
locations.forEach(({ source, start }, index) => {
|
|
52
|
+
let positions = bySource.get(source);
|
|
53
|
+
|
|
54
|
+
if (positions === undefined) {
|
|
55
|
+
positions = [];
|
|
56
|
+
bySource.set(source, positions);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
positions.push({
|
|
60
|
+
position: start,
|
|
61
|
+
index,
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
const result = new Array(locations.length);
|
|
65
|
+
|
|
66
|
+
for (const [source, positions] of bySource) {
|
|
67
|
+
const lineRegexp = /\r\n|[\n\r]/g;
|
|
68
|
+
let match = lineRegexp.exec(source.body);
|
|
69
|
+
let line = 1;
|
|
70
|
+
let lastLineStart = 0; // These arrays are local; sorting never changes the caller's input.
|
|
71
|
+
|
|
72
|
+
positions.sort((a, b) => a.position - b.position);
|
|
73
|
+
|
|
74
|
+
for (const { position, index } of positions) {
|
|
75
|
+
while (match !== null && match.index < position) {
|
|
76
|
+
lastLineStart = match.index + match[0].length;
|
|
77
|
+
line++;
|
|
78
|
+
match = lineRegexp.exec(source.body);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
result[index] = {
|
|
82
|
+
line,
|
|
83
|
+
column: position + 1 - lastLineStart,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return result;
|
|
89
|
+
}
|