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
1145
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.0 to 9.0.1-rc-20231122143721-5e398bc5

4

cjs/extensions.js

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

function mergeExtensions(extensions) {
return (0, utils_1.mergeDeep)(extensions);
return (0, utils_1.mergeDeep)(extensions, false, true);
}

@@ -16,3 +16,3 @@ exports.mergeExtensions = mergeExtensions;

}
obj.extensions = (0, utils_1.mergeDeep)([obj.extensions || {}, extensions || {}]);
obj.extensions = (0, utils_1.mergeDeep)([obj.extensions || {}, extensions || {}], false, true);
}

@@ -19,0 +19,0 @@ function applyExtensions(schema, extensions) {

@@ -35,3 +35,4 @@ "use strict";

function mergeResolvers(resolversDefinitions, options) {
if (!resolversDefinitions || (Array.isArray(resolversDefinitions) && resolversDefinitions.length === 0)) {
if (!resolversDefinitions ||
(Array.isArray(resolversDefinitions) && resolversDefinitions.length === 0)) {
return {};

@@ -38,0 +39,0 @@ }

@@ -59,3 +59,4 @@ "use strict";

for (const directive of asFirst) {
if (directiveAlreadyExists(result, directive) && !isRepeatableDirective(directive, directives)) {
if (directiveAlreadyExists(result, directive) &&
!isRepeatableDirective(directive, directives)) {
const existingDirectiveIndex = result.findIndex(d => d.name.value === directive.name.value);

@@ -62,0 +63,0 @@ const existingDirective = result[existingDirectiveIndex];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeEnumValues = void 0;
const utils_1 = require("@graphql-tools/utils");
const directives_js_1 = require("./directives.js");
const utils_1 = require("@graphql-tools/utils");
function mergeEnumValues(first, second, config, directives) {

@@ -7,0 +7,0 @@ if (config?.consistentEnumMerge) {

@@ -12,3 +12,5 @@ "use strict";

description: e1['description'] || e2['description'],
kind: config?.convertExtensions || e1.kind === 'EnumTypeDefinition' || e2.kind === 'EnumTypeDefinition'
kind: config?.convertExtensions ||
e1.kind === 'EnumTypeDefinition' ||
e2.kind === 'EnumTypeDefinition'
? 'EnumTypeDefinition'

@@ -15,0 +17,0 @@ : 'EnumTypeExtension',

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeFields = void 0;
const utils_js_1 = require("./utils.js");
const directives_js_1 = require("./directives.js");
const utils_1 = require("@graphql-tools/utils");
const arguments_js_1 = require("./arguments.js");
const directives_js_1 = require("./directives.js");
const utils_js_1 = require("./utils.js");
function fieldAlreadyExists(fieldsArr, otherField) {

@@ -21,3 +21,4 @@ const resultIndex = fieldsArr.findIndex(field => field.name.value === otherField.name.value);

if (existing && !config?.ignoreFieldConflicts) {
const newField = (config?.onFieldTypeConflict && config.onFieldTypeConflict(existing, field, type, config?.throwOnConflict)) ||
const newField = (config?.onFieldTypeConflict &&
config.onFieldTypeConflict(existing, field, type, config?.throwOnConflict)) ||
preventConflicts(type, existing, field, config?.throwOnConflict);

@@ -24,0 +25,0 @@ newField.arguments = (0, arguments_js_1.mergeArguments)(field['arguments'] || [], existing['arguments'] || [], config);

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

const graphql_1 = require("graphql");
const directives_js_1 = require("./directives.js");
const fields_js_1 = require("./fields.js");
const directives_js_1 = require("./directives.js");
function mergeInputType(node, existingNode, config, directives) {

@@ -9,0 +9,0 @@ if (existingNode) {

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

const graphql_1 = require("graphql");
const directives_js_1 = require("./directives.js");
const fields_js_1 = require("./fields.js");
const directives_js_1 = require("./directives.js");
const merge_named_type_array_js_1 = require("./merge-named-type-array.js");

@@ -9,0 +9,0 @@ function mergeInterface(node, existingNode, config, directives) {

@@ -5,11 +5,11 @@ "use strict";

const graphql_1 = require("graphql");
const type_js_1 = require("./type.js");
const utils_1 = require("@graphql-tools/utils");
const directives_js_1 = require("./directives.js");
const enum_js_1 = require("./enum.js");
const scalar_js_1 = require("./scalar.js");
const union_js_1 = require("./union.js");
const input_type_js_1 = require("./input-type.js");
const interface_js_1 = require("./interface.js");
const directives_js_1 = require("./directives.js");
const scalar_js_1 = require("./scalar.js");
const schema_def_js_1 = require("./schema-def.js");
const utils_1 = require("@graphql-tools/utils");
const type_js_1 = require("./type.js");
const union_js_1 = require("./union.js");
exports.schemaDefSymbol = 'SCHEMA_DEF_SYMBOL';

@@ -66,3 +66,4 @@ function isNamedDefinitionNode(definitionNode) {

}
else if (nodeDefinition.kind === graphql_1.Kind.SCHEMA_DEFINITION || nodeDefinition.kind === graphql_1.Kind.SCHEMA_EXTENSION) {
else if (nodeDefinition.kind === graphql_1.Kind.SCHEMA_DEFINITION ||
nodeDefinition.kind === graphql_1.Kind.SCHEMA_EXTENSION) {
mergedResultMap[exports.schemaDefSymbol] = (0, schema_def_js_1.mergeSchemaDefs)(nodeDefinition, mergedResultMap[exports.schemaDefSymbol], config);

@@ -69,0 +70,0 @@ }

@@ -5,6 +5,6 @@ "use strict";

const graphql_1 = require("graphql");
const utils_js_1 = require("./utils.js");
const utils_1 = require("@graphql-tools/utils");
const merge_nodes_js_1 = require("./merge-nodes.js");
const utils_1 = require("@graphql-tools/utils");
const schema_def_js_1 = require("./schema-def.js");
const utils_js_1 = require("./utils.js");
function mergeTypeDefs(typeSource, config) {

@@ -11,0 +11,0 @@ (0, utils_1.resetComments)();

@@ -14,3 +14,4 @@ "use strict";

for (const opNodeType in exports.DEFAULT_OPERATION_TYPE_NAME_MAP) {
const opNode = opNodeList.find(n => n.operation === opNodeType) || existingOpNodeList.find(n => n.operation === opNodeType);
const opNode = opNodeList.find(n => n.operation === opNodeType) ||
existingOpNodeList.find(n => n.operation === opNodeType);
if (opNode) {

@@ -17,0 +18,0 @@ finalOpNodeList.push(opNode);

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

const graphql_1 = require("graphql");
const directives_js_1 = require("./directives.js");
const fields_js_1 = require("./fields.js");
const directives_js_1 = require("./directives.js");
const merge_named_type_array_js_1 = require("./merge-named-type-array.js");

@@ -9,0 +9,0 @@ function mergeType(node, existingNode, config, directives) {

@@ -14,3 +14,5 @@ "use strict";

directives: (0, directives_js_1.mergeDirectives)(first.directives, second.directives, config, directives),
kind: config?.convertExtensions || first.kind === 'UnionTypeDefinition' || second.kind === 'UnionTypeDefinition'
kind: config?.convertExtensions ||
first.kind === 'UnionTypeDefinition' ||
second.kind === 'UnionTypeDefinition'
? graphql_1.Kind.UNION_TYPE_DEFINITION

@@ -17,0 +19,0 @@ : graphql_1.Kind.UNION_TYPE_EXTENSION,

@@ -48,3 +48,3 @@ "use strict";

CompareVal[CompareVal["A_GREATER_THAN_B"] = 1] = "A_GREATER_THAN_B";
})(CompareVal = exports.CompareVal || (exports.CompareVal = {}));
})(CompareVal || (exports.CompareVal = CompareVal = {}));
function defaultStringComparator(a, b) {

@@ -51,0 +51,0 @@ if (a == null && b == null) {

import { mergeDeep } from '@graphql-tools/utils';
export { extractExtensionsFromSchema } from '@graphql-tools/utils';
export function mergeExtensions(extensions) {
return mergeDeep(extensions);
return mergeDeep(extensions, false, true);
}

@@ -10,3 +10,3 @@ function applyExtensionObject(obj, extensions) {

}
obj.extensions = mergeDeep([obj.extensions || {}, extensions || {}]);
obj.extensions = mergeDeep([obj.extensions || {}, extensions || {}], false, true);
}

@@ -13,0 +13,0 @@ export function applyExtensions(schema, extensions) {

@@ -32,3 +32,4 @@ import { mergeDeep } from '@graphql-tools/utils';

export function mergeResolvers(resolversDefinitions, options) {
if (!resolversDefinitions || (Array.isArray(resolversDefinitions) && resolversDefinitions.length === 0)) {
if (!resolversDefinitions ||
(Array.isArray(resolversDefinitions) && resolversDefinitions.length === 0)) {
return {};

@@ -35,0 +36,0 @@ }

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

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

@@ -56,3 +56,4 @@ function directiveAlreadyExists(directivesArr, otherDirective) {

for (const directive of asFirst) {
if (directiveAlreadyExists(result, directive) && !isRepeatableDirective(directive, directives)) {
if (directiveAlreadyExists(result, directive) &&
!isRepeatableDirective(directive, directives)) {
const existingDirectiveIndex = result.findIndex(d => d.name.value === directive.name.value);

@@ -59,0 +60,0 @@ const existingDirective = result[existingDirectiveIndex];

@@ -0,3 +1,3 @@

import { compareNodes } from '@graphql-tools/utils';
import { mergeDirectives } from './directives.js';
import { compareNodes } from '@graphql-tools/utils';
export function mergeEnumValues(first, second, config, directives) {

@@ -4,0 +4,0 @@ if (config?.consistentEnumMerge) {

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

import { Kind } from 'graphql';
import { Kind, } from 'graphql';
import { mergeDirectives } from './directives.js';

@@ -9,3 +9,5 @@ import { mergeEnumValues } from './enum-values.js';

description: e1['description'] || e2['description'],
kind: config?.convertExtensions || e1.kind === 'EnumTypeDefinition' || e2.kind === 'EnumTypeDefinition'
kind: config?.convertExtensions ||
e1.kind === 'EnumTypeDefinition' ||
e2.kind === 'EnumTypeDefinition'
? 'EnumTypeDefinition'

@@ -12,0 +14,0 @@ : 'EnumTypeExtension',

@@ -1,5 +0,5 @@

import { extractType, isWrappingTypeNode, isListTypeNode, isNonNullTypeNode, printTypeNode } from './utils.js';
import { mergeDirectives } from './directives.js';
import { compareNodes } from '@graphql-tools/utils';
import { mergeArguments } from './arguments.js';
import { mergeDirectives } from './directives.js';
import { extractType, isListTypeNode, isNonNullTypeNode, isWrappingTypeNode, printTypeNode, } from './utils.js';
function fieldAlreadyExists(fieldsArr, otherField) {

@@ -18,3 +18,4 @@ const resultIndex = fieldsArr.findIndex(field => field.name.value === otherField.name.value);

if (existing && !config?.ignoreFieldConflicts) {
const newField = (config?.onFieldTypeConflict && config.onFieldTypeConflict(existing, field, type, config?.throwOnConflict)) ||
const newField = (config?.onFieldTypeConflict &&
config.onFieldTypeConflict(existing, field, type, config?.throwOnConflict)) ||
preventConflicts(type, existing, field, config?.throwOnConflict);

@@ -21,0 +22,0 @@ newField.arguments = mergeArguments(field['arguments'] || [], existing['arguments'] || [], config);

import { Kind, } from 'graphql';
import { mergeDirectives } from './directives.js';
import { mergeFields } from './fields.js';
import { mergeDirectives } from './directives.js';
export function mergeInputType(node, existingNode, config, directives) {

@@ -5,0 +5,0 @@ if (existingNode) {

@@ -1,4 +0,4 @@

import { Kind } from 'graphql';
import { Kind, } from 'graphql';
import { mergeDirectives } from './directives.js';
import { mergeFields } from './fields.js';
import { mergeDirectives } from './directives.js';
import { mergeNamedTypeArray } from './merge-named-type-array.js';

@@ -5,0 +5,0 @@ export function mergeInterface(node, existingNode, config, directives) {

@@ -1,11 +0,11 @@

import { Kind } from 'graphql';
import { mergeType } from './type.js';
import { Kind, } from 'graphql';
import { collectComment } from '@graphql-tools/utils';
import { mergeDirective } from './directives.js';
import { mergeEnum } from './enum.js';
import { mergeScalar } from './scalar.js';
import { mergeUnion } from './union.js';
import { mergeInputType } from './input-type.js';
import { mergeInterface } from './interface.js';
import { mergeDirective } from './directives.js';
import { mergeScalar } from './scalar.js';
import { mergeSchemaDefs } from './schema-def.js';
import { collectComment } from '@graphql-tools/utils';
import { mergeType } from './type.js';
import { mergeUnion } from './union.js';
export const schemaDefSymbol = 'SCHEMA_DEF_SYMBOL';

@@ -61,3 +61,4 @@ export function isNamedDefinitionNode(definitionNode) {

}
else if (nodeDefinition.kind === Kind.SCHEMA_DEFINITION || nodeDefinition.kind === Kind.SCHEMA_EXTENSION) {
else if (nodeDefinition.kind === Kind.SCHEMA_DEFINITION ||
nodeDefinition.kind === Kind.SCHEMA_EXTENSION) {
mergedResultMap[schemaDefSymbol] = mergeSchemaDefs(nodeDefinition, mergedResultMap[schemaDefSymbol], config);

@@ -64,0 +65,0 @@ }

@@ -1,6 +0,6 @@

import { parse, Kind, isSchema, isDefinitionNode, } from 'graphql';
import { defaultStringComparator, isSourceTypes, isStringTypes } from './utils.js';
import { isDefinitionNode, isSchema, Kind, parse, } from 'graphql';
import { getDocumentNodeFromSchema, isDocumentNode, printWithComments, resetComments, } from '@graphql-tools/utils';
import { mergeGraphQLNodes, schemaDefSymbol } from './merge-nodes.js';
import { getDocumentNodeFromSchema, isDocumentNode, resetComments, printWithComments, } from '@graphql-tools/utils';
import { DEFAULT_OPERATION_TYPE_NAME_MAP } from './schema-def.js';
import { defaultStringComparator, isSourceTypes, isStringTypes } from './utils.js';
export function mergeTypeDefs(typeSource, config) {

@@ -7,0 +7,0 @@ resetComments();

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

import { Kind } from 'graphql';
import { Kind, } from 'graphql';
import { mergeDirectives } from './directives.js';

@@ -3,0 +3,0 @@ export function mergeScalar(node, existingNode, config, directives) {

@@ -11,3 +11,4 @@ import { Kind, } from 'graphql';

for (const opNodeType in DEFAULT_OPERATION_TYPE_NAME_MAP) {
const opNode = opNodeList.find(n => n.operation === opNodeType) || existingOpNodeList.find(n => n.operation === opNodeType);
const opNode = opNodeList.find(n => n.operation === opNodeType) ||
existingOpNodeList.find(n => n.operation === opNodeType);
if (opNode) {

@@ -14,0 +15,0 @@ finalOpNodeList.push(opNode);

@@ -1,4 +0,4 @@

import { Kind } from 'graphql';
import { Kind, } from 'graphql';
import { mergeDirectives } from './directives.js';
import { mergeFields } from './fields.js';
import { mergeDirectives } from './directives.js';
import { mergeNamedTypeArray } from './merge-named-type-array.js';

@@ -5,0 +5,0 @@ export function mergeType(node, existingNode, config, directives) {

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

import { Kind } from 'graphql';
import { Kind, } from 'graphql';
import { mergeDirectives } from './directives.js';

@@ -11,3 +11,5 @@ import { mergeNamedTypeArray } from './merge-named-type-array.js';

directives: mergeDirectives(first.directives, second.directives, config, directives),
kind: config?.convertExtensions || first.kind === 'UnionTypeDefinition' || second.kind === 'UnionTypeDefinition'
kind: config?.convertExtensions ||
first.kind === 'UnionTypeDefinition' ||
second.kind === 'UnionTypeDefinition'
? Kind.UNION_TYPE_DEFINITION

@@ -14,0 +16,0 @@ : Kind.UNION_TYPE_EXTENSION,

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

import { Source, Kind } from 'graphql';
import { Kind, Source } from 'graphql';
export function isStringTypes(types) {

@@ -3,0 +3,0 @@ return typeof types === 'string';

{
"name": "@graphql-tools/merge",
"version": "9.0.0",
"version": "9.0.1-rc-20231122143721-5e398bc5",
"description": "A set of utils for faster development of GraphQL tools",

@@ -10,3 +10,3 @@ "sideEffects": false,

"dependencies": {
"@graphql-tools/utils": "^10.0.0",
"@graphql-tools/utils": "10.0.10-rc-20231122143721-5e398bc5",
"tslib": "^2.4.0"

@@ -13,0 +13,0 @@ },

@@ -1,4 +0,4 @@

import { DirectiveNode, DirectiveDefinitionNode } from 'graphql';
import { DirectiveDefinitionNode, DirectiveNode } from 'graphql';
import { Config } from './merge-typedefs.js';
export declare function mergeDirectives(d1?: ReadonlyArray<DirectiveNode>, d2?: ReadonlyArray<DirectiveNode>, config?: Config, directives?: Record<string, DirectiveDefinitionNode>): DirectiveNode[];
export declare function mergeDirective(node: DirectiveDefinitionNode, existingNode?: DirectiveDefinitionNode): DirectiveDefinitionNode;

@@ -0,3 +1,3 @@

import { DirectiveDefinitionNode, FieldDefinitionNode, InputValueDefinitionNode, NameNode } from 'graphql';
import { Config } from './merge-typedefs.js';
import { FieldDefinitionNode, InputValueDefinitionNode, NameNode, DirectiveDefinitionNode } from 'graphql';
type FieldDefNode = FieldDefinitionNode | InputValueDefinitionNode;

@@ -4,0 +4,0 @@ type NamedDefNode = {

@@ -0,3 +1,3 @@

import { DirectiveDefinitionNode, InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode } from 'graphql';
import { Config } from './merge-typedefs.js';
import { InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode, DirectiveDefinitionNode } from 'graphql';
export declare function mergeInputType(node: InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode, existingNode: InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode, config?: Config, directives?: Record<string, DirectiveDefinitionNode>): InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode;

@@ -0,3 +1,3 @@

import { DirectiveDefinitionNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode } from 'graphql';
import { Config } from './merge-typedefs.js';
import { DirectiveDefinitionNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode } from 'graphql';
export declare function mergeInterface(node: InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode, existingNode: InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode, config?: Config, directives?: Record<string, DirectiveDefinitionNode>): InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode;

@@ -1,4 +0,4 @@

import { Config } from './merge-typedefs.js';
import { DefinitionNode, DirectiveDefinitionNode, SchemaDefinitionNode, SchemaExtensionNode } from 'graphql';
import { NamedDefinitionNode } from '@graphql-tools/utils';
import { Config } from './merge-typedefs.js';
export declare const schemaDefSymbol = "SCHEMA_DEF_SYMBOL";

@@ -5,0 +5,0 @@ export type MergedResultMap = Record<string, NamedDefinitionNode> & {

import { DefinitionNode, DocumentNode, ParseOptions } from 'graphql';
import { CompareFn } from './utils.js';
import { GetDocumentNodeFromSchemaOptions, TypeSource } from '@graphql-tools/utils';
import { OnFieldTypeConflict } from './fields.js';
import { CompareFn } from './utils.js';
type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;

@@ -6,0 +6,0 @@ export interface Config extends ParseOptions, GetDocumentNodeFromSchemaOptions {

@@ -0,3 +1,3 @@

import { DirectiveDefinitionNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode } from 'graphql';
import { Config } from './merge-typedefs.js';
import { DirectiveDefinitionNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode } from 'graphql';
export declare function mergeType(node: ObjectTypeDefinitionNode | ObjectTypeExtensionNode, existingNode: ObjectTypeDefinitionNode | ObjectTypeExtensionNode, config?: Config, directives?: Record<string, DirectiveDefinitionNode>): ObjectTypeDefinitionNode | ObjectTypeExtensionNode;

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

import { TypeNode, NamedTypeNode, ListTypeNode, NonNullTypeNode, Source } from 'graphql';
import { ListTypeNode, NamedTypeNode, NonNullTypeNode, Source, TypeNode } from 'graphql';
export declare function isStringTypes(types: any): types is string;

@@ -3,0 +3,0 @@ export declare function isSourceTypes(types: any): types is Source;

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