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.0.0 to 3.1.0

.turbo/turbo-type.log

6

CHANGELOG.md
# Change Log
## 3.1.0
### Minor Changes
- 4094e70a: Add initial support for new federation plugin
## 3.0.0

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

1

esm/index.d.ts

@@ -14,4 +14,5 @@ import './global-types';

afterBuild(schema: GraphQLSchema): GraphQLSchema;
mergeDirectives(left: DirectiveList | Record<string, {}>, right: DirectiveList | Record<string, {}>): DirectiveList | Record<string, {}>;
normalizeDirectives(directives: DirectiveList | Record<string, {}>): DirectiveList | Record<string, {}>;
}
//# sourceMappingURL=index.d.ts.map

@@ -10,4 +10,5 @@ /* eslint-disable no-param-reassign */

onOutputFieldConfig(fieldConfig) {
var _a, _b;
const options = fieldConfig.pothosOptions;
if (!options.directives) {
if (!options.directives && !((_a = fieldConfig.extensions) === null || _a === void 0 ? void 0 : _a.directives)) {
return fieldConfig;

@@ -19,3 +20,3 @@ }

...fieldConfig.extensions,
directives: this.normalizeDirectives(options.directives),
directives: this.normalizeDirectives(this.mergeDirectives((_b = fieldConfig.extensions) === null || _b === void 0 ? void 0 : _b.directives, options.directives)),
},

@@ -25,2 +26,3 @@ };

onInputFieldConfig(fieldConfig) {
var _a;
const options = fieldConfig.pothosOptions;

@@ -34,3 +36,3 @@ if (!options.directives) {

...fieldConfig.extensions,
directives: this.normalizeDirectives(options.directives),
directives: this.normalizeDirectives(this.mergeDirectives((_a = fieldConfig.extensions) === null || _a === void 0 ? void 0 : _a.directives, options.directives)),
},

@@ -40,2 +42,3 @@ };

onEnumValueConfig(valueConfig) {
var _a;
const options = valueConfig.pothosOptions;

@@ -49,3 +52,3 @@ if (!options.directives) {

...valueConfig.extensions,
directives: this.normalizeDirectives(options.directives),
directives: this.normalizeDirectives(this.mergeDirectives((_a = valueConfig.extensions) === null || _a === void 0 ? void 0 : _a.directives, options.directives)),
},

@@ -55,2 +58,3 @@ };

onTypeConfig(typeConfig) {
var _a;
const options = typeConfig.pothosOptions;

@@ -64,3 +68,3 @@ if (!options.directives) {

...typeConfig.extensions,
directives: this.normalizeDirectives(options.directives),
directives: this.normalizeDirectives(this.mergeDirectives((_a = typeConfig.extensions) === null || _a === void 0 ? void 0 : _a.directives, options.directives)),
},

@@ -73,2 +77,15 @@ };

}
mergeDirectives(left, right) {
if (!(left && right)) {
return left || right;
}
return [
...(Array.isArray(left)
? left
: Object.keys(left).map((name) => ({ name, args: left[name] }))),
...(Array.isArray(right)
? right
: Object.keys(right).map((name) => ({ name, args: right[name] }))),
];
}
normalizeDirectives(directives) {

@@ -75,0 +92,0 @@ if (this.builder.options.useGraphQLToolsUnorderedDirectives) {

13

esm/mock-ast.js

@@ -115,6 +115,11 @@ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */

? directives
: Object.keys(directives).map((name) => ({
name,
args: directives[name],
}));
: Object.keys(directives).flatMap((name) => Array.isArray(directives[name])
? directives[name].map((args) => ({
name,
args,
}))
: {
name,
args: directives[name],
});
return directiveList.map((directive) => ({

@@ -121,0 +126,0 @@ kind: Kind.DIRECTIVE,

@@ -14,4 +14,5 @@ import './global-types';

afterBuild(schema: GraphQLSchema): GraphQLSchema;
mergeDirectives(left: DirectiveList | Record<string, {}>, right: DirectiveList | Record<string, {}>): DirectiveList | Record<string, {}>;
normalizeDirectives(directives: DirectiveList | Record<string, {}>): DirectiveList | Record<string, {}>;
}
//# sourceMappingURL=index.d.ts.map

@@ -38,4 +38,5 @@ "use strict";

onOutputFieldConfig(fieldConfig) {
var _a, _b;
const options = fieldConfig.pothosOptions;
if (!options.directives) {
if (!options.directives && !((_a = fieldConfig.extensions) === null || _a === void 0 ? void 0 : _a.directives)) {
return fieldConfig;

@@ -47,3 +48,3 @@ }

...fieldConfig.extensions,
directives: this.normalizeDirectives(options.directives),
directives: this.normalizeDirectives(this.mergeDirectives((_b = fieldConfig.extensions) === null || _b === void 0 ? void 0 : _b.directives, options.directives)),
},

@@ -53,2 +54,3 @@ };

onInputFieldConfig(fieldConfig) {
var _a;
const options = fieldConfig.pothosOptions;

@@ -62,3 +64,3 @@ if (!options.directives) {

...fieldConfig.extensions,
directives: this.normalizeDirectives(options.directives),
directives: this.normalizeDirectives(this.mergeDirectives((_a = fieldConfig.extensions) === null || _a === void 0 ? void 0 : _a.directives, options.directives)),
},

@@ -68,2 +70,3 @@ };

onEnumValueConfig(valueConfig) {
var _a;
const options = valueConfig.pothosOptions;

@@ -77,3 +80,3 @@ if (!options.directives) {

...valueConfig.extensions,
directives: this.normalizeDirectives(options.directives),
directives: this.normalizeDirectives(this.mergeDirectives((_a = valueConfig.extensions) === null || _a === void 0 ? void 0 : _a.directives, options.directives)),
},

@@ -83,2 +86,3 @@ };

onTypeConfig(typeConfig) {
var _a;
const options = typeConfig.pothosOptions;

@@ -92,3 +96,3 @@ if (!options.directives) {

...typeConfig.extensions,
directives: this.normalizeDirectives(options.directives),
directives: this.normalizeDirectives(this.mergeDirectives((_a = typeConfig.extensions) === null || _a === void 0 ? void 0 : _a.directives, options.directives)),
},

@@ -101,2 +105,15 @@ };

}
mergeDirectives(left, right) {
if (!(left && right)) {
return left || right;
}
return [
...(Array.isArray(left)
? left
: Object.keys(left).map((name) => ({ name, args: left[name] }))),
...(Array.isArray(right)
? right
: Object.keys(right).map((name) => ({ name, args: right[name] }))),
];
}
normalizeDirectives(directives) {

@@ -103,0 +120,0 @@ if (this.builder.options.useGraphQLToolsUnorderedDirectives) {

@@ -118,6 +118,11 @@ "use strict";

? directives
: Object.keys(directives).map((name) => ({
name,
args: directives[name],
}));
: Object.keys(directives).flatMap((name) => Array.isArray(directives[name])
? directives[name].map((args) => ({
name,
args,
}))
: {
name,
args: directives[name],
});
return directiveList.map((directive) => ({

@@ -124,0 +129,0 @@ kind: graphql_1.Kind.DIRECTIVE,

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

@@ -36,3 +36,3 @@ "main": "./lib/index.js",

"devDependencies": {
"@pothos/core": "^3.0.0",
"@pothos/core": "^3.1.0",
"@pothos/test-utils": "^1.0.0",

@@ -39,0 +39,0 @@ "graphql": "16.2.0",

@@ -24,3 +24,3 @@ /* eslint-disable no-param-reassign */

if (!options.directives) {
if (!options.directives && !fieldConfig.extensions?.directives) {
return fieldConfig;

@@ -33,3 +33,8 @@ }

...fieldConfig.extensions,
directives: this.normalizeDirectives(options.directives as unknown as Record<string, {}>),
directives: this.normalizeDirectives(
this.mergeDirectives(
fieldConfig.extensions?.directives as Record<string, {}>,
options.directives as unknown as Record<string, {}>,
),
),
},

@@ -50,3 +55,8 @@ };

...fieldConfig.extensions,
directives: this.normalizeDirectives(options.directives as unknown as Record<string, {}>),
directives: this.normalizeDirectives(
this.mergeDirectives(
fieldConfig.extensions?.directives as Record<string, {}>,
options.directives as unknown as Record<string, {}>,
),
),
},

@@ -67,3 +77,8 @@ };

...valueConfig.extensions,
directives: this.normalizeDirectives(options.directives as unknown as Record<string, {}>),
directives: this.normalizeDirectives(
this.mergeDirectives(
valueConfig.extensions?.directives as Record<string, {}>,
options.directives as unknown as Record<string, {}>,
),
),
},

@@ -84,3 +99,8 @@ };

...typeConfig.extensions,
directives: this.normalizeDirectives(options.directives as unknown as Record<string, {}>),
directives: this.normalizeDirectives(
this.mergeDirectives(
typeConfig.extensions?.directives as Record<string, {}>,
options.directives as unknown as Record<string, {}>,
),
),
},

@@ -96,2 +116,20 @@ };

mergeDirectives(
left: DirectiveList | Record<string, {}>,
right: DirectiveList | Record<string, {}>,
) {
if (!(left && right)) {
return left || right;
}
return [
...(Array.isArray(left)
? left
: Object.keys(left).map((name) => ({ name, args: left[name] }))),
...(Array.isArray(right)
? right
: Object.keys(right).map((name) => ({ name, args: right[name] }))),
];
}
normalizeDirectives(directives: DirectiveList | Record<string, {}>) {

@@ -98,0 +136,0 @@ if (this.builder.options.useGraphQLToolsUnorderedDirectives) {

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

import {
ArgumentNode,
DirectiveNode,

@@ -146,9 +147,16 @@ EnumValueDefinitionNode,

function directiveNodes(directives: DirectiveList | Record<string, {}>) {
function directiveNodes(directives: DirectiveList | Record<string, {}>): readonly DirectiveNode[] {
const directiveList = Array.isArray(directives)
? directives
: Object.keys(directives).map((name) => ({
name,
args: directives[name],
}));
: Object.keys(directives).flatMap((name) =>
Array.isArray(directives[name])
? (directives[name] as {}[]).map((args) => ({
name,
args,
}))
: {
name,
args: directives[name],
},
);

@@ -161,9 +169,11 @@ return directiveList.map(

directive.args &&
Object.keys(directive.args).map((argName) => ({
kind: Kind.ARGUMENT,
name: { kind: Kind.NAME, value: argName },
value: valueNode((directive.args as Record<string, unknown>)[argName]),
})),
Object.keys(directive.args).map(
(argName): ArgumentNode => ({
kind: Kind.ARGUMENT,
name: { kind: Kind.NAME, value: argName },
value: valueNode((directive.args as Record<string, unknown>)[argName]),
}),
),
}),
);
) as readonly DirectiveNode[];
}

@@ -170,0 +180,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

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

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