Socket
Socket
Sign inDemoInstall

@graphql-tools/utils

Package Overview
Dependencies
Maintainers
0
Versions
1269
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 10.3.1 to 10.3.2-rc-20240713150409-15fe1251509201546823652fac8f8918c78ec0cd

46

cjs/prune.js

@@ -108,8 +108,3 @@ "use strict";

// Visit enum values directives argument types
queue.push(...type.getValues().flatMap(value => {
if (value.astNode) {
return getDirectivesArgumentsTypeNames(schema, value.astNode);
}
return [];
}));
queue.push(...type.getValues().flatMap(value => getDirectivesArgumentsTypeNames(schema, value)));
}

@@ -133,5 +128,3 @@ // Visit interfaces this type is implementing if they haven't been visited yet

const typeNames = [(0, graphql_1.getNamedType)(arg.type).name];
if (arg.astNode) {
typeNames.push(...getDirectivesArgumentsTypeNames(schema, arg.astNode));
}
typeNames.push(...getDirectivesArgumentsTypeNames(schema, arg));
return typeNames;

@@ -142,5 +135,3 @@ }));

queue.push(namedType.name);
if (field.astNode) {
queue.push(...getDirectivesArgumentsTypeNames(schema, field.astNode));
}
queue.push(...getDirectivesArgumentsTypeNames(schema, field));
// Interfaces returned on fields need to be revisited to add their implementations

@@ -152,5 +143,3 @@ if ((0, graphql_1.isInterfaceType)(namedType) && !(namedType.name in revisit)) {

}
if (type.astNode) {
queue.push(...getDirectivesArgumentsTypeNames(schema, type.astNode));
}
queue.push(...getDirectivesArgumentsTypeNames(schema, type));
visited.add(typeName); // Mark as visited (and therefore it is used and should be kept)

@@ -161,4 +150,27 @@ }

}
function getDirectivesArgumentsTypeNames(schema, astNode) {
return (astNode.directives ?? []).flatMap(directive => schema.getDirective(directive.name.value)?.args.map(arg => (0, graphql_1.getNamedType)(arg.type).name) ?? []);
function getDirectivesArgumentsTypeNames(schema, directableObj) {
const argTypeNames = new Set();
if (directableObj.astNode?.directives) {
for (const directiveNode of directableObj.astNode.directives) {
const directive = schema.getDirective(directiveNode.name.value);
if (directive?.args) {
for (const arg of directive.args) {
const argType = (0, graphql_1.getNamedType)(arg.type);
argTypeNames.add(argType.name);
}
}
}
}
if (directableObj.extensions?.['directives']) {
for (const directiveName in directableObj.extensions['directives']) {
const directive = schema.getDirective(directiveName);
if (directive?.args) {
for (const arg of directive.args) {
const argType = (0, graphql_1.getNamedType)(arg.type);
argTypeNames.add(argType.name);
}
}
}
}
return [...argTypeNames];
}

@@ -104,8 +104,3 @@ import { getNamedType, isEnumType, isInputObjectType, isInterfaceType, isObjectType, isScalarType, isSpecifiedScalarType, isUnionType, } from 'graphql';

// Visit enum values directives argument types
queue.push(...type.getValues().flatMap(value => {
if (value.astNode) {
return getDirectivesArgumentsTypeNames(schema, value.astNode);
}
return [];
}));
queue.push(...type.getValues().flatMap(value => getDirectivesArgumentsTypeNames(schema, value)));
}

@@ -129,5 +124,3 @@ // Visit interfaces this type is implementing if they haven't been visited yet

const typeNames = [getNamedType(arg.type).name];
if (arg.astNode) {
typeNames.push(...getDirectivesArgumentsTypeNames(schema, arg.astNode));
}
typeNames.push(...getDirectivesArgumentsTypeNames(schema, arg));
return typeNames;

@@ -138,5 +131,3 @@ }));

queue.push(namedType.name);
if (field.astNode) {
queue.push(...getDirectivesArgumentsTypeNames(schema, field.astNode));
}
queue.push(...getDirectivesArgumentsTypeNames(schema, field));
// Interfaces returned on fields need to be revisited to add their implementations

@@ -148,5 +139,3 @@ if (isInterfaceType(namedType) && !(namedType.name in revisit)) {

}
if (type.astNode) {
queue.push(...getDirectivesArgumentsTypeNames(schema, type.astNode));
}
queue.push(...getDirectivesArgumentsTypeNames(schema, type));
visited.add(typeName); // Mark as visited (and therefore it is used and should be kept)

@@ -157,4 +146,27 @@ }

}
function getDirectivesArgumentsTypeNames(schema, astNode) {
return (astNode.directives ?? []).flatMap(directive => schema.getDirective(directive.name.value)?.args.map(arg => getNamedType(arg.type).name) ?? []);
function getDirectivesArgumentsTypeNames(schema, directableObj) {
const argTypeNames = new Set();
if (directableObj.astNode?.directives) {
for (const directiveNode of directableObj.astNode.directives) {
const directive = schema.getDirective(directiveNode.name.value);
if (directive?.args) {
for (const arg of directive.args) {
const argType = getNamedType(arg.type);
argTypeNames.add(argType.name);
}
}
}
}
if (directableObj.extensions?.['directives']) {
for (const directiveName in directableObj.extensions['directives']) {
const directive = schema.getDirective(directiveName);
if (directive?.args) {
for (const arg of directive.args) {
const argType = getNamedType(arg.type);
argTypeNames.add(argType.name);
}
}
}
}
return [...argTypeNames];
}
{
"name": "@graphql-tools/utils",
"version": "10.3.1",
"version": "10.3.2-rc-20240713150409-15fe1251509201546823652fac8f8918c78ec0cd",
"description": "Common package containing utils and types for GraphQL tools",

@@ -5,0 +5,0 @@ "sideEffects": false,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc