@graphql-tools/utils 7.2.4-alpha-08ab8c06.0 → 7.2.5
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/es5/index.cjs.js +6 -21
- package/es5/index.cjs.js.map +1 -1
- package/es5/index.esm.js +9 -24
- package/es5/index.esm.js.map +1 -1
- package/es5/package.json +2 -2
- package/index.cjs.js +6 -21
- package/index.cjs.js.map +1 -1
- package/index.esm.js +9 -24
- package/index.esm.js.map +1 -1
- package/package.json +2 -2
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parse, isNonNullType, GraphQLError, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedScalarType, isIntrospectionType, astFromValue, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, isSpecifiedDirective, GraphQLDeprecatedDirective, specifiedRules, validate, buildSchema, Source, TokenKind, visit, isTypeSystemDefinitionNode, buildClientSchema, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isSchema, isInputType, valueFromASTUntyped, isDirective, getDirectiveValues
|
|
1
|
+
import { parse, isNonNullType, GraphQLError, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedScalarType, isIntrospectionType, astFromValue, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, isSpecifiedDirective, GraphQLDeprecatedDirective, specifiedRules, validate, buildSchema, Source, TokenKind, visit, isTypeSystemDefinitionNode, buildClientSchema, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isSchema, isInputType, valueFromASTUntyped, isDirective, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, typeFromAST, isAbstractType, isCompositeType, doTypesOverlap, getOperationAST, getOperationRootType } from 'graphql';
|
|
2
2
|
import AggregateError from '@ardatan/aggregate-error';
|
|
3
3
|
import { camelCase } from 'camel-case';
|
|
4
4
|
|
|
@@ -262,20 +262,16 @@ function getDirectives(schema, node, pathToDirectivesInExtensions = ['directives
|
|
|
262
262
|
const result = {};
|
|
263
263
|
astNodes.forEach(astNode => {
|
|
264
264
|
if (astNode.directives) {
|
|
265
|
-
astNode.directives.forEach(
|
|
266
|
-
|
|
265
|
+
astNode.directives.forEach(directiveNode => {
|
|
266
|
+
var _a;
|
|
267
|
+
const schemaDirective = schemaDirectiveMap[directiveNode.name.value];
|
|
267
268
|
if (schemaDirective) {
|
|
268
|
-
const directiveValue = getDirectiveValues(schemaDirective, astNode);
|
|
269
269
|
if (schemaDirective.isRepeatable) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
result[schemaDirective.name] = [directiveValue];
|
|
275
|
-
}
|
|
270
|
+
result[schemaDirective.name] = (_a = result[schemaDirective.name]) !== null && _a !== void 0 ? _a : [];
|
|
271
|
+
result[schemaDirective.name].push(getArgumentValues(schemaDirective, directiveNode));
|
|
276
272
|
}
|
|
277
273
|
else {
|
|
278
|
-
result[schemaDirective.name] =
|
|
274
|
+
result[schemaDirective.name] = getArgumentValues(schemaDirective, directiveNode);
|
|
279
275
|
}
|
|
280
276
|
}
|
|
281
277
|
});
|
|
@@ -283,17 +279,6 @@ function getDirectives(schema, node, pathToDirectivesInExtensions = ['directives
|
|
|
283
279
|
});
|
|
284
280
|
return result;
|
|
285
281
|
}
|
|
286
|
-
// graphql-js getDirectiveValues does not handle repeatable directives
|
|
287
|
-
function getDirectiveValues(directiveDef, node) {
|
|
288
|
-
if (node.directives) {
|
|
289
|
-
if (directiveDef.isRepeatable) {
|
|
290
|
-
const directiveNodes = node.directives.filter(directive => directive.name.value === directiveDef.name);
|
|
291
|
-
return directiveNodes.map(directiveNode => getArgumentValues(directiveDef, directiveNode));
|
|
292
|
-
}
|
|
293
|
-
const directiveNode = node.directives.find(directive => directive.name.value === directiveDef.name);
|
|
294
|
-
return getArgumentValues(directiveDef, directiveNode);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
282
|
|
|
298
283
|
function parseDirectiveValue(value) {
|
|
299
284
|
switch (value.kind) {
|
|
@@ -3767,11 +3752,11 @@ function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFra
|
|
|
3767
3752
|
* directives, where @skip has higher precedence than @include.
|
|
3768
3753
|
*/
|
|
3769
3754
|
function shouldIncludeNode(exeContext, node) {
|
|
3770
|
-
const skip = getDirectiveValues
|
|
3755
|
+
const skip = getDirectiveValues(GraphQLSkipDirective, node, exeContext.variableValues);
|
|
3771
3756
|
if ((skip === null || skip === void 0 ? void 0 : skip.if) === true) {
|
|
3772
3757
|
return false;
|
|
3773
3758
|
}
|
|
3774
|
-
const include = getDirectiveValues
|
|
3759
|
+
const include = getDirectiveValues(GraphQLIncludeDirective, node, exeContext.variableValues);
|
|
3775
3760
|
if ((include === null || include === void 0 ? void 0 : include.if) === false) {
|
|
3776
3761
|
return false;
|
|
3777
3762
|
}
|