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

@graphql-tools/merge

Package Overview
Dependencies
Maintainers
3
Versions
1126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/merge - npm Package Compare versions

Comparing version 9.0.1 to 9.0.2-rc-20240220122323-43df81236732631d10ea769020a3736f18c7e06d

19

cjs/typedefs-mergers/directives.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeDirective = exports.mergeDirectives = void 0;
const graphql_1 = require("graphql");
const utils_1 = require("@graphql-tools/utils");

@@ -72,23 +71,7 @@ function directiveAlreadyExists(directivesArr, otherDirective) {

exports.mergeDirectives = mergeDirectives;
function validateInputs(node, existingNode) {
const printedNode = (0, graphql_1.print)({
...node,
description: undefined,
});
const printedExistingNode = (0, graphql_1.print)({
...existingNode,
description: undefined,
});
// eslint-disable-next-line
const leaveInputs = new RegExp('(directive @w*d*)|( on .*$)', 'g');
const sameArguments = printedNode.replace(leaveInputs, '') === printedExistingNode.replace(leaveInputs, '');
if (!sameArguments) {
throw new Error(`Unable to merge GraphQL directive "${node.name.value}". \nExisting directive: \n\t${printedExistingNode} \nReceived directive: \n\t${printedNode}`);
}
}
function mergeDirective(node, existingNode) {
if (existingNode) {
validateInputs(node, existingNode);
return {
...node,
arguments: deduplicateLists(existingNode.arguments || [], node.arguments || [], (arg, existingArgs) => !nameAlreadyExists(arg.name, existingArgs.map(a => a.name))),
locations: [

@@ -95,0 +78,0 @@ ...existingNode.locations,

@@ -1,2 +0,1 @@

import { print, } from 'graphql';
import { isSome } from '@graphql-tools/utils';

@@ -68,23 +67,7 @@ function directiveAlreadyExists(directivesArr, otherDirective) {

}
function validateInputs(node, existingNode) {
const printedNode = print({
...node,
description: undefined,
});
const printedExistingNode = print({
...existingNode,
description: undefined,
});
// eslint-disable-next-line
const leaveInputs = new RegExp('(directive @w*d*)|( on .*$)', 'g');
const sameArguments = printedNode.replace(leaveInputs, '') === printedExistingNode.replace(leaveInputs, '');
if (!sameArguments) {
throw new Error(`Unable to merge GraphQL directive "${node.name.value}". \nExisting directive: \n\t${printedExistingNode} \nReceived directive: \n\t${printedNode}`);
}
}
export function mergeDirective(node, existingNode) {
if (existingNode) {
validateInputs(node, existingNode);
return {
...node,
arguments: deduplicateLists(existingNode.arguments || [], node.arguments || [], (arg, existingArgs) => !nameAlreadyExists(arg.name, existingArgs.map(a => a.name))),
locations: [

@@ -91,0 +74,0 @@ ...existingNode.locations,

2

package.json
{
"name": "@graphql-tools/merge",
"version": "9.0.1",
"version": "9.0.2-rc-20240220122323-43df81236732631d10ea769020a3736f18c7e06d",
"description": "A set of utils for faster development of GraphQL tools",

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

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