@graphql-tools/utils
Advanced tools
Comparing version 10.5.1 to 10.5.2
@@ -8,30 +8,39 @@ "use strict"; | ||
const directiveExtensions = {}; | ||
if (directableObj.astNode?.directives?.length) { | ||
for (const directive of directableObj.astNode.directives) { | ||
const directiveName = directive.name.value; | ||
let existingDirectiveExtensions = directiveExtensions[directiveName]; | ||
if (!existingDirectiveExtensions) { | ||
existingDirectiveExtensions = []; | ||
directiveExtensions[directiveName] = existingDirectiveExtensions; | ||
} | ||
const directiveInSchema = schema?.getDirective(directiveName); | ||
let value = {}; | ||
if (directiveInSchema) { | ||
value = (0, getArgumentValues_js_1.getArgumentValues)(directiveInSchema, directive); | ||
} | ||
if (directive.arguments) { | ||
for (const argNode of directive.arguments) { | ||
const argName = argNode.name.value; | ||
if (value[argName] == null) { | ||
const argInDirective = directiveInSchema?.args.find(arg => arg.name === argName); | ||
if (argInDirective) { | ||
value[argName] = (0, graphql_1.valueFromAST)(argNode.value, argInDirective.type); | ||
const astNodes = []; | ||
if (directableObj.astNode) { | ||
astNodes.push(directableObj.astNode); | ||
} | ||
if (directableObj.extensionASTNodes) { | ||
astNodes.push(...directableObj.extensionASTNodes); | ||
} | ||
for (const astNode of astNodes) { | ||
if (astNode.directives?.length) { | ||
for (const directive of astNode.directives) { | ||
const directiveName = directive.name.value; | ||
let existingDirectiveExtensions = directiveExtensions[directiveName]; | ||
if (!existingDirectiveExtensions) { | ||
existingDirectiveExtensions = []; | ||
directiveExtensions[directiveName] = existingDirectiveExtensions; | ||
} | ||
const directiveInSchema = schema?.getDirective(directiveName); | ||
let value = {}; | ||
if (directiveInSchema) { | ||
value = (0, getArgumentValues_js_1.getArgumentValues)(directiveInSchema, directive); | ||
} | ||
if (directive.arguments) { | ||
for (const argNode of directive.arguments) { | ||
const argName = argNode.name.value; | ||
if (value[argName] == null) { | ||
const argInDirective = directiveInSchema?.args.find(arg => arg.name === argName); | ||
if (argInDirective) { | ||
value[argName] = (0, graphql_1.valueFromAST)(argNode.value, argInDirective.type); | ||
} | ||
} | ||
if (value[argName] == null) { | ||
value[argName] = (0, graphql_1.valueFromASTUntyped)(argNode.value); | ||
} | ||
} | ||
if (value[argName] == null) { | ||
value[argName] = (0, graphql_1.valueFromASTUntyped)(argNode.value); | ||
} | ||
} | ||
existingDirectiveExtensions.push(value); | ||
} | ||
existingDirectiveExtensions.push(value); | ||
} | ||
@@ -38,0 +47,0 @@ } |
@@ -5,30 +5,39 @@ import { valueFromAST, valueFromASTUntyped } from 'graphql'; | ||
const directiveExtensions = {}; | ||
if (directableObj.astNode?.directives?.length) { | ||
for (const directive of directableObj.astNode.directives) { | ||
const directiveName = directive.name.value; | ||
let existingDirectiveExtensions = directiveExtensions[directiveName]; | ||
if (!existingDirectiveExtensions) { | ||
existingDirectiveExtensions = []; | ||
directiveExtensions[directiveName] = existingDirectiveExtensions; | ||
} | ||
const directiveInSchema = schema?.getDirective(directiveName); | ||
let value = {}; | ||
if (directiveInSchema) { | ||
value = getArgumentValues(directiveInSchema, directive); | ||
} | ||
if (directive.arguments) { | ||
for (const argNode of directive.arguments) { | ||
const argName = argNode.name.value; | ||
if (value[argName] == null) { | ||
const argInDirective = directiveInSchema?.args.find(arg => arg.name === argName); | ||
if (argInDirective) { | ||
value[argName] = valueFromAST(argNode.value, argInDirective.type); | ||
const astNodes = []; | ||
if (directableObj.astNode) { | ||
astNodes.push(directableObj.astNode); | ||
} | ||
if (directableObj.extensionASTNodes) { | ||
astNodes.push(...directableObj.extensionASTNodes); | ||
} | ||
for (const astNode of astNodes) { | ||
if (astNode.directives?.length) { | ||
for (const directive of astNode.directives) { | ||
const directiveName = directive.name.value; | ||
let existingDirectiveExtensions = directiveExtensions[directiveName]; | ||
if (!existingDirectiveExtensions) { | ||
existingDirectiveExtensions = []; | ||
directiveExtensions[directiveName] = existingDirectiveExtensions; | ||
} | ||
const directiveInSchema = schema?.getDirective(directiveName); | ||
let value = {}; | ||
if (directiveInSchema) { | ||
value = getArgumentValues(directiveInSchema, directive); | ||
} | ||
if (directive.arguments) { | ||
for (const argNode of directive.arguments) { | ||
const argName = argNode.name.value; | ||
if (value[argName] == null) { | ||
const argInDirective = directiveInSchema?.args.find(arg => arg.name === argName); | ||
if (argInDirective) { | ||
value[argName] = valueFromAST(argNode.value, argInDirective.type); | ||
} | ||
} | ||
if (value[argName] == null) { | ||
value[argName] = valueFromASTUntyped(argNode.value); | ||
} | ||
} | ||
if (value[argName] == null) { | ||
value[argName] = valueFromASTUntyped(argNode.value); | ||
} | ||
} | ||
existingDirectiveExtensions.push(value); | ||
} | ||
existingDirectiveExtensions.push(value); | ||
} | ||
@@ -35,0 +44,0 @@ } |
{ | ||
"name": "@graphql-tools/utils", | ||
"version": "10.5.1", | ||
"version": "10.5.2", | ||
"description": "Common package containing utils and types for GraphQL tools", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -7,2 +7,3 @@ import type { ASTNode, DirectiveNode, GraphQLSchema } from 'graphql'; | ||
astNode?: DirectableASTNode | null; | ||
extensionASTNodes?: readonly DirectableASTNode[] | null; | ||
extensions?: { | ||
@@ -9,0 +10,0 @@ directives?: Record<string, any>; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
508374
10942