Documentation
API Reference
Packages
merge

@graphql-tools/merge

Enumerations

Interfaces

Type Aliases

Variables

Functions

Type Aliases

CompareFn

Ƭ CompareFn<T>: (a: T | undefined, b: T | undefined) => -1 | 0 | 1

Type parameters

Name
T

Type declaration

▸ (a, b): -1 | 0 | 1

Parameters
NameType
aT | undefined
bT | undefined
Returns

-1 | 0 | 1

Defined in

packages/merge/src/typedefs-mergers/utils.ts:48


MergedResultMap

Ƭ MergedResultMap: Record<string, NamedDefinitionNode> & { SCHEMA_DEF_SYMBOL: SchemaDefinitionNode | SchemaExtensionNode }

Defined in

packages/merge/src/typedefs-mergers/merge-nodes.ts:22


OnFieldTypeConflict

Ƭ OnFieldTypeConflict: (existingField: FieldDefNode, otherField: FieldDefNode, type: NamedDefNode, ignoreNullability: boolean | undefined) => FieldDefNode

Type declaration

▸ (existingField, otherField, type, ignoreNullability): FieldDefNode

Parameters
NameType
existingFieldFieldDefNode
otherFieldFieldDefNode
typeNamedDefNode
ignoreNullabilityboolean | undefined
Returns

FieldDefNode

Defined in

packages/merge/src/typedefs-mergers/fields.ts:23

Variables

schemaDefSymbol

Const schemaDefSymbol: "SCHEMA_DEF_SYMBOL"

Defined in

packages/merge/src/typedefs-mergers/merge-nodes.ts:20

Functions

applyExtensions

applyExtensions(schema, extensions): GraphQLSchema

Parameters

NameType
schemaGraphQLSchema
extensionsSchemaExtensions

Returns

GraphQLSchema

Defined in

packages/merge/src/extensions.ts:21


defaultStringComparator

defaultStringComparator(a, b): CompareVal

Parameters

NameType
aundefined | string
bundefined | string

Returns

CompareVal

Defined in

packages/merge/src/typedefs-mergers/utils.ts:50


extractExtensionsFromSchema

extractExtensionsFromSchema(schema): SchemaExtensions

Parameters

NameType
schemaGraphQLSchema

Returns

SchemaExtensions

Defined in

packages/utils/src/extractExtensionsFromSchema.ts:27


extractType

extractType(type): NamedTypeNode

Parameters

NameType
typeTypeNode

Returns

NamedTypeNode

Defined in

packages/merge/src/typedefs-mergers/utils.ts:11


isListTypeNode

isListTypeNode(type): type is ListTypeNode

Parameters

NameType
typeTypeNode

Returns

type is ListTypeNode

Defined in

packages/merge/src/typedefs-mergers/utils.ts:23


isNamedDefinitionNode

isNamedDefinitionNode(definitionNode): definitionNode is NamedDefinitionNode

Parameters

NameType
definitionNodeDefinitionNode

Returns

definitionNode is NamedDefinitionNode

Defined in

packages/merge/src/typedefs-mergers/merge-nodes.ts:26


isNonNullTypeNode

isNonNullTypeNode(type): type is NonNullTypeNode

Parameters

NameType
typeTypeNode

Returns

type is NonNullTypeNode

Defined in

packages/merge/src/typedefs-mergers/utils.ts:27


isSourceTypes

isSourceTypes(types): types is Source

Parameters

NameType
typesany

Returns

types is Source

Defined in

packages/merge/src/typedefs-mergers/utils.ts:7


isStringTypes

isStringTypes(types): types is string

Parameters

NameType
typesany

Returns

types is string

Defined in

packages/merge/src/typedefs-mergers/utils.ts:3


isWrappingTypeNode

isWrappingTypeNode(type): type is ListTypeNode | NonNullTypeNode

Parameters

NameType
typeTypeNode

Returns

type is ListTypeNode | NonNullTypeNode

Defined in

packages/merge/src/typedefs-mergers/utils.ts:19


mergeArguments

mergeArguments(args1, args2, config?): InputValueDefinitionNode[]

Parameters

NameType
args1InputValueDefinitionNode[]
args2InputValueDefinitionNode[]
config?Config

Returns

InputValueDefinitionNode[]

Defined in

packages/merge/src/typedefs-mergers/arguments.ts:5


mergeDirective

mergeDirective(node, existingNode?): DirectiveDefinitionNode

Parameters

NameType
nodeDirectiveDefinitionNode
existingNode?DirectiveDefinitionNode

Returns

DirectiveDefinitionNode

Defined in

packages/merge/src/typedefs-mergers/directives.ts:115


mergeDirectives

mergeDirectives(d1?, d2?, config?, directives?): DirectiveNode[]

Parameters

NameTypeDefault value
d1readonly DirectiveNode[][]
d2readonly DirectiveNode[][]
config?Configundefined
directives?Record<string, DirectiveDefinitionNode>undefined

Returns

DirectiveNode[]

Defined in

packages/merge/src/typedefs-mergers/directives.ts:85


mergeEnum

mergeEnum(e1, e2, config?, directives?): EnumTypeDefinitionNode | EnumTypeExtensionNode

Parameters

NameType
e1EnumTypeDefinitionNode | EnumTypeExtensionNode
e2EnumTypeDefinitionNode | EnumTypeExtensionNode
config?Config
directives?Record<string, DirectiveDefinitionNode>

Returns

EnumTypeDefinitionNode | EnumTypeExtensionNode

Defined in

packages/merge/src/typedefs-mergers/enum.ts:11


mergeEnumValues

mergeEnumValues(first, second, config?, directives?): EnumValueDefinitionNode[]

Parameters

NameType
firstundefined | readonly EnumValueDefinitionNode[]
secondundefined | readonly EnumValueDefinitionNode[]
config?Config
directives?Record<string, DirectiveDefinitionNode>

Returns

EnumValueDefinitionNode[]

Defined in

packages/merge/src/typedefs-mergers/enum-values.ts:6


mergeExtensions

mergeExtensions(extensions): SchemaExtensions

Parameters

NameType
extensionsSchemaExtensions[]

Returns

SchemaExtensions

Defined in

packages/merge/src/extensions.ts:6


mergeFields

mergeFields<T>(type, f1, f2, config?, directives?): T[]

Type parameters

NameType
Textends FieldDefNode

Parameters

NameType
typeObject
type.nameNameNode
f1undefined | readonly T[]
f2undefined | readonly T[]
config?Config
directives?Record<string, DirectiveDefinitionNode>

Returns

T[]

Defined in

packages/merge/src/typedefs-mergers/fields.ts:41


mergeGraphQLNodes

mergeGraphQLNodes(nodes, config?, directives?): MergedResultMap

Parameters

NameType
nodesreadonly DefinitionNode[]
config?Config
directivesRecord<string, DirectiveDefinitionNode>

Returns

MergedResultMap

Defined in

packages/merge/src/typedefs-mergers/merge-nodes.ts:32


mergeGraphQLTypes

mergeGraphQLTypes(typeSource, config): DefinitionNode[]

Parameters

NameType
typeSourceTypeSource
configConfig

Returns

DefinitionNode[]

Defined in

packages/merge/src/typedefs-mergers/merge-typedefs.ts:198


mergeInputType

mergeInputType(node, existingNode, config?, directives?): InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode

Parameters

NameType
nodeInputObjectTypeDefinitionNode | InputObjectTypeExtensionNode
existingNodeInputObjectTypeDefinitionNode | InputObjectTypeExtensionNode
config?Config
directives?Record<string, DirectiveDefinitionNode>

Returns

InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode

Defined in

packages/merge/src/typedefs-mergers/input-type.ts:12


mergeInterface

mergeInterface(node, existingNode, config?, directives?): InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode

Parameters

NameType
nodeInterfaceTypeDefinitionNode | InterfaceTypeExtensionNode
existingNodeInterfaceTypeDefinitionNode | InterfaceTypeExtensionNode
config?Config
directives?Record<string, DirectiveDefinitionNode>

Returns

InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode

Defined in

packages/merge/src/typedefs-mergers/interface.ts:12


mergeNamedTypeArray

mergeNamedTypeArray(first?, second?, config?): NamedTypeNode[]

Parameters

NameTypeDefault value
firstreadonly NamedTypeNode[][]
secondreadonly NamedTypeNode[][]
configConfig{}

Returns

NamedTypeNode[]

Defined in

packages/merge/src/typedefs-mergers/merge-named-type-array.ts:9


mergeResolvers

mergeResolvers<TSource, TContext>(resolversDefinitions, options?): IResolvers<TSource, TContext>

Deep merges multiple resolver definition objects into a single definition.

Type parameters

Name
TSource
TContext

Parameters

NameTypeDescription
resolversDefinitionsundefined | null | IResolvers<TSource, TContext> | Maybe<IResolvers<TSource, TContext>>[]Resolver definitions to be merged
options?MergeResolversOptionsAdditional options js const { mergeResolvers } = require('@graphql-tools/merge'); const clientResolver = require('./clientResolver'); const productResolver = require('./productResolver'); const resolvers = mergeResolvers([ clientResolver, productResolver, ]); If you don’t want to manually create the array of resolver objects, you can also use this function along with loadFiles: js const path = require('path'); const { mergeResolvers } = require('@graphql-tools/merge'); const { loadFilesSync } = require('@graphql-tools/load-files'); const resolversArray = loadFilesSync(path.join(__dirname, './resolvers')); const resolvers = mergeResolvers(resolversArray)

Returns

IResolvers<TSource, TContext>

Defined in

packages/merge/src/merge-resolvers.ts:39


mergeScalar

mergeScalar(node, existingNode, config?, directives?): ScalarTypeDefinitionNode | ScalarTypeExtensionNode

Parameters

NameType
nodeScalarTypeDefinitionNode | ScalarTypeExtensionNode
existingNodeScalarTypeDefinitionNode | ScalarTypeExtensionNode
config?Config
directives?Record<string, DirectiveDefinitionNode>

Returns

ScalarTypeDefinitionNode | ScalarTypeExtensionNode

Defined in

packages/merge/src/typedefs-mergers/scalar.ts:10


mergeType

mergeType(node, existingNode, config?, directives?): ObjectTypeDefinitionNode | ObjectTypeExtensionNode

Parameters

NameType
nodeObjectTypeDefinitionNode | ObjectTypeExtensionNode
existingNodeObjectTypeDefinitionNode | ObjectTypeExtensionNode
config?Config
directives?Record<string, DirectiveDefinitionNode>

Returns

ObjectTypeDefinitionNode | ObjectTypeExtensionNode

Defined in

packages/merge/src/typedefs-mergers/type.ts:12


mergeTypeDefs

mergeTypeDefs(typeSource): DocumentNode

Merges multiple type definitions into a single DocumentNode

Parameters

NameType
typeSourceTypeSource

Returns

DocumentNode

Defined in

packages/merge/src/typedefs-mergers/merge-typedefs.ts:103

mergeTypeDefs(typeSource, config?): string

Parameters

NameType
typeSourceTypeSource
config?Partial<Config> & { commentDescriptions: true }

Returns

string

Defined in

packages/merge/src/typedefs-mergers/merge-typedefs.ts:104

mergeTypeDefs(typeSource, config?): DocumentNode

Parameters

NameType
typeSourceTypeSource
config?Omit<Partial<Config>, "commentDescriptions">

Returns

DocumentNode

Defined in

packages/merge/src/typedefs-mergers/merge-typedefs.ts:108


mergeUnion

mergeUnion(first, second, config?, directives?): UnionTypeDefinitionNode | UnionTypeExtensionNode

Parameters

NameType
firstUnionTypeDefinitionNode | UnionTypeExtensionNode
secondUnionTypeDefinitionNode | UnionTypeExtensionNode
config?Config
directives?Record<string, DirectiveDefinitionNode>

Returns

UnionTypeDefinitionNode | UnionTypeExtensionNode

Defined in

packages/merge/src/typedefs-mergers/union.ts:11


printTypeNode

printTypeNode(type): string

Parameters

NameType
typeTypeNode

Returns

string

Defined in

packages/merge/src/typedefs-mergers/utils.ts:31