Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pothos/plugin-directives

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pothos/plugin-directives - npm Package Compare versions

Comparing version 3.7.4 to 3.8.0

6

CHANGELOG.md
# Change Log
## 3.8.0
### Minor Changes
- 4c086637: Add deprecated directive to mock ast nodes
## 3.7.4

@@ -4,0 +10,0 @@

43

esm/mock-ast.js

@@ -8,3 +8,2 @@ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ /* eslint-disable no-param-reassign */ import './global-types.js';

if (type instanceof GraphQLObjectType) {
var ref;
type.astNode = {

@@ -22,7 +21,6 @@ kind: Kind.OBJECT_TYPE_DEFINITION,

fields: fieldNodes(type.getFields()),
directives: ((ref = type.extensions) === null || ref === void 0 ? void 0 : ref.directives) ? directiveNodes(type.extensions.directives) : []
directives: directiveNodes(type.extensions.directives)
};
}
else if (type instanceof GraphQLInterfaceType) {
var ref1;
type.astNode = {

@@ -40,7 +38,6 @@ kind: Kind.INTERFACE_TYPE_DEFINITION,

fields: fieldNodes(type.getFields()),
directives: ((ref1 = type.extensions) === null || ref1 === void 0 ? void 0 : ref1.directives) ? directiveNodes(type.extensions.directives) : []
directives: directiveNodes(type.extensions.directives)
};
}
else if (type instanceof GraphQLUnionType) {
var ref2;
type.astNode = {

@@ -57,7 +54,6 @@ kind: Kind.UNION_TYPE_DEFINITION,

types: type.getTypes().map((iface) => typeNode(iface)),
directives: ((ref2 = type.extensions) === null || ref2 === void 0 ? void 0 : ref2.directives) ? directiveNodes(type.extensions.directives) : []
directives: directiveNodes(type.extensions.directives)
};
}
else if (type instanceof GraphQLEnumType) {
var ref3;
type.astNode = {

@@ -74,7 +70,6 @@ kind: Kind.ENUM_TYPE_DEFINITION,

values: enumValueNodes(type.getValues()),
directives: ((ref3 = type.extensions) === null || ref3 === void 0 ? void 0 : ref3.directives) ? directiveNodes(type.extensions.directives) : []
directives: directiveNodes(type.extensions.directives)
};
}
else if (type instanceof GraphQLScalarType) {
var ref4;
type.astNode = {

@@ -90,7 +85,6 @@ kind: Kind.SCALAR_TYPE_DEFINITION,

} : undefined,
directives: ((ref4 = type.extensions) === null || ref4 === void 0 ? void 0 : ref4.directives) ? directiveNodes(type.extensions.directives) : []
directives: directiveNodes(type.extensions.directives)
};
}
else if (type instanceof GraphQLInputObjectType) {
var ref5;
type.astNode = {

@@ -107,3 +101,3 @@ kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,

fields: inputFieldNodes(type.getFields()),
directives: ((ref5 = type.extensions) === null || ref5 === void 0 ? void 0 : ref5.directives) ? directiveNodes(type.extensions.directives) : []
directives: directiveNodes(type.extensions.directives)
};

@@ -163,3 +157,6 @@ }

}
function directiveNodes(directives) {
function directiveNodes(directives, deprecationReason) {
if (!directives) {
return [];
}
const directiveList = Array.isArray(directives) ? directives : Object.keys(directives).flatMap((name) => Array.isArray(directives[name]) ? directives[name].map((args) => ({

@@ -172,2 +169,10 @@ name,

});
if (deprecationReason) {
directiveList.unshift({
name: "deprecated",
args: {
reason: deprecationReason
}
});
}
return directiveList.map((directive) => ({

@@ -191,3 +196,2 @@ kind: Kind.DIRECTIVE,

return Object.keys(fields).map((fieldName) => {
var ref;
const field = fields[fieldName];

@@ -206,3 +210,3 @@ field.astNode = {

type: typeNode(field.type),
directives: ((ref = field.extensions) === null || ref === void 0 ? void 0 : ref.directives) ? directiveNodes(field.extensions.directives) : []
directives: directiveNodes(field.extensions.directives, field.deprecationReason)
};

@@ -214,3 +218,2 @@ return field.astNode;

return Object.keys(fields).map((fieldName) => {
var ref;
const field = fields[fieldName];

@@ -228,3 +231,3 @@ field.astNode = {

type: typeNode(field.type),
directives: ((ref = field.extensions) === null || ref === void 0 ? void 0 : ref.directives) ? directiveNodes(field.extensions.directives) : []
directives: directiveNodes(field.extensions.directives, field.deprecationReason)
};

@@ -236,3 +239,2 @@ return field.astNode;

return args.map((arg) => {
var ref;
arg.astNode = {

@@ -249,3 +251,3 @@ kind: Kind.INPUT_VALUE_DEFINITION,

type: typeNode(arg.type),
directives: ((ref = arg.extensions) === null || ref === void 0 ? void 0 : ref.directives) ? directiveNodes(arg.extensions.directives) : []
directives: directiveNodes(arg.extensions.directives, arg.deprecationReason)
};

@@ -257,3 +259,2 @@ return arg.astNode;

return values.map((value) => {
var ref;
value.astNode = {

@@ -269,3 +270,3 @@ kind: Kind.ENUM_VALUE_DEFINITION,

},
directives: ((ref = value.extensions) === null || ref === void 0 ? void 0 : ref.directives) ? directiveNodes(value.extensions.directives) : []
directives: directiveNodes(value.extensions.directives, value.deprecationReason)
};

@@ -272,0 +273,0 @@ return value.astNode;

@@ -16,3 +16,2 @@ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ /* eslint-disable no-param-reassign */ "use strict";

if (type instanceof _graphql.GraphQLObjectType) {
var ref;
type.astNode = {

@@ -30,6 +29,5 @@ kind: _graphql.Kind.OBJECT_TYPE_DEFINITION,

fields: fieldNodes(type.getFields()),
directives: ((ref = type.extensions) === null || ref === void 0 ? void 0 : ref.directives) ? directiveNodes(type.extensions.directives) : []
directives: directiveNodes(type.extensions.directives)
};
} else if (type instanceof _graphql.GraphQLInterfaceType) {
var ref1;
type.astNode = {

@@ -47,6 +45,5 @@ kind: _graphql.Kind.INTERFACE_TYPE_DEFINITION,

fields: fieldNodes(type.getFields()),
directives: ((ref1 = type.extensions) === null || ref1 === void 0 ? void 0 : ref1.directives) ? directiveNodes(type.extensions.directives) : []
directives: directiveNodes(type.extensions.directives)
};
} else if (type instanceof _graphql.GraphQLUnionType) {
var ref2;
type.astNode = {

@@ -63,6 +60,5 @@ kind: _graphql.Kind.UNION_TYPE_DEFINITION,

types: type.getTypes().map((iface)=>typeNode(iface)),
directives: ((ref2 = type.extensions) === null || ref2 === void 0 ? void 0 : ref2.directives) ? directiveNodes(type.extensions.directives) : []
directives: directiveNodes(type.extensions.directives)
};
} else if (type instanceof _graphql.GraphQLEnumType) {
var ref3;
type.astNode = {

@@ -79,6 +75,5 @@ kind: _graphql.Kind.ENUM_TYPE_DEFINITION,

values: enumValueNodes(type.getValues()),
directives: ((ref3 = type.extensions) === null || ref3 === void 0 ? void 0 : ref3.directives) ? directiveNodes(type.extensions.directives) : []
directives: directiveNodes(type.extensions.directives)
};
} else if (type instanceof _graphql.GraphQLScalarType) {
var ref4;
type.astNode = {

@@ -94,6 +89,5 @@ kind: _graphql.Kind.SCALAR_TYPE_DEFINITION,

} : undefined,
directives: ((ref4 = type.extensions) === null || ref4 === void 0 ? void 0 : ref4.directives) ? directiveNodes(type.extensions.directives) : []
directives: directiveNodes(type.extensions.directives)
};
} else if (type instanceof _graphql.GraphQLInputObjectType) {
var ref5;
type.astNode = {

@@ -110,3 +104,3 @@ kind: _graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION,

fields: inputFieldNodes(type.getFields()),
directives: ((ref5 = type.extensions) === null || ref5 === void 0 ? void 0 : ref5.directives) ? directiveNodes(type.extensions.directives) : []
directives: directiveNodes(type.extensions.directives)
};

@@ -166,3 +160,6 @@ }

}
function directiveNodes(directives) {
function directiveNodes(directives, deprecationReason) {
if (!directives) {
return [];
}
const directiveList = Array.isArray(directives) ? directives : Object.keys(directives).flatMap((name)=>Array.isArray(directives[name]) ? directives[name].map((args)=>({

@@ -175,2 +172,10 @@ name,

});
if (deprecationReason) {
directiveList.unshift({
name: 'deprecated',
args: {
reason: deprecationReason
}
});
}
return directiveList.map((directive)=>({

@@ -194,3 +199,2 @@ kind: _graphql.Kind.DIRECTIVE,

return Object.keys(fields).map((fieldName)=>{
var ref;
const field = fields[fieldName];

@@ -209,3 +213,3 @@ field.astNode = {

type: typeNode(field.type),
directives: ((ref = field.extensions) === null || ref === void 0 ? void 0 : ref.directives) ? directiveNodes(field.extensions.directives) : []
directives: directiveNodes(field.extensions.directives, field.deprecationReason)
};

@@ -217,3 +221,2 @@ return field.astNode;

return Object.keys(fields).map((fieldName)=>{
var ref;
const field = fields[fieldName];

@@ -231,3 +234,3 @@ field.astNode = {

type: typeNode(field.type),
directives: ((ref = field.extensions) === null || ref === void 0 ? void 0 : ref.directives) ? directiveNodes(field.extensions.directives) : []
directives: directiveNodes(field.extensions.directives, field.deprecationReason)
};

@@ -239,3 +242,2 @@ return field.astNode;

return args.map((arg)=>{
var ref;
arg.astNode = {

@@ -252,3 +254,3 @@ kind: _graphql.Kind.INPUT_VALUE_DEFINITION,

type: typeNode(arg.type),
directives: ((ref = arg.extensions) === null || ref === void 0 ? void 0 : ref.directives) ? directiveNodes(arg.extensions.directives) : []
directives: directiveNodes(arg.extensions.directives, arg.deprecationReason)
};

@@ -260,3 +262,2 @@ return arg.astNode;

return values.map((value)=>{
var ref;
value.astNode = {

@@ -272,3 +273,3 @@ kind: _graphql.Kind.ENUM_VALUE_DEFINITION,

},
directives: ((ref = value.extensions) === null || ref === void 0 ? void 0 : ref.directives) ? directiveNodes(value.extensions.directives) : []
directives: directiveNodes(value.extensions.directives, value.deprecationReason)
};

@@ -275,0 +276,0 @@ return value.astNode;

{
"name": "@pothos/plugin-directives",
"version": "3.7.4",
"version": "3.8.0",
"description": "Directive plugin for Pothos, enables using graphql-tools based directives with Pothos",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -7,2 +7,3 @@ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */

ArgumentNode,
ConstDirectiveNode,
DirectiveNode,

@@ -50,5 +51,3 @@ EnumValueDefinitionNode,

fields: fieldNodes(type.getFields()),
directives: (type.extensions?.directives
? directiveNodes(type.extensions.directives as DirectiveList)
: []) as [],
directives: directiveNodes(type.extensions.directives as DirectiveList),
};

@@ -62,5 +61,3 @@ } else if (type instanceof GraphQLInterfaceType) {

fields: fieldNodes(type.getFields()),
directives: (type.extensions?.directives
? directiveNodes(type.extensions.directives as DirectiveList)
: []) as [],
directives: directiveNodes(type.extensions.directives as DirectiveList),
};

@@ -73,5 +70,3 @@ } else if (type instanceof GraphQLUnionType) {

types: type.getTypes().map((iface) => typeNode(iface) as NamedTypeNode),
directives: (type.extensions?.directives
? directiveNodes(type.extensions.directives as DirectiveList)
: []) as [],
directives: directiveNodes(type.extensions.directives as DirectiveList),
};

@@ -84,5 +79,3 @@ } else if (type instanceof GraphQLEnumType) {

values: enumValueNodes(type.getValues()),
directives: (type.extensions?.directives
? directiveNodes(type.extensions.directives as DirectiveList)
: []) as [],
directives: directiveNodes(type.extensions.directives as DirectiveList),
};

@@ -94,5 +87,3 @@ } else if (type instanceof GraphQLScalarType) {

description: type.description ? { kind: Kind.STRING, value: type.description } : undefined,
directives: (type.extensions?.directives
? directiveNodes(type.extensions.directives as DirectiveList)
: []) as [],
directives: directiveNodes(type.extensions.directives as DirectiveList),
};

@@ -105,5 +96,3 @@ } else if (type instanceof GraphQLInputObjectType) {

fields: inputFieldNodes(type.getFields()),
directives: (type.extensions?.directives
? directiveNodes(type.extensions.directives as DirectiveList)
: []) as [],
directives: directiveNodes(type.extensions.directives as DirectiveList),
};

@@ -153,3 +142,10 @@ }

function directiveNodes(directives: DirectiveList | Record<string, {}>): readonly DirectiveNode[] {
function directiveNodes(
directives: DirectiveList | Record<string, {}> | undefined,
deprecationReason?: string | null,
): readonly ConstDirectiveNode[] {
if (!directives) {
return [];
}
const directiveList = Array.isArray(directives)

@@ -169,2 +165,11 @@ ? directives

if (deprecationReason) {
directiveList.unshift({
name: 'deprecated',
args: {
reason: deprecationReason!,
},
});
}
return directiveList.map(

@@ -184,3 +189,3 @@ (directive): DirectiveNode => ({

}),
) as readonly DirectiveNode[];
) as readonly ConstDirectiveNode[];
}

@@ -198,5 +203,6 @@

type: typeNode(field.type),
directives: (field.extensions?.directives
? directiveNodes(field.extensions.directives as DirectiveList)
: []) as [],
directives: directiveNodes(
field.extensions.directives as DirectiveList,
field.deprecationReason,
),
};

@@ -217,5 +223,6 @@

type: typeNode(field.type),
directives: (field.extensions?.directives
? directiveNodes(field.extensions.directives as DirectiveList)
: []) as [],
directives: directiveNodes(
field.extensions.directives as DirectiveList,
field.deprecationReason,
),
};

@@ -234,5 +241,3 @@

type: typeNode(arg.type),
directives: (arg.extensions?.directives
? directiveNodes(arg.extensions.directives as DirectiveList)
: []) as [],
directives: directiveNodes(arg.extensions.directives as DirectiveList, arg.deprecationReason),
};

@@ -250,5 +255,6 @@

name: { kind: Kind.NAME, value: value.name },
directives: (value.extensions?.directives
? directiveNodes(value.extensions.directives as DirectiveList)
: []) as [],
directives: directiveNodes(
value.extensions.directives as DirectiveList,
value.deprecationReason,
),
};

@@ -255,0 +261,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc