On This Page

  • Docs
  • API Reference
  • Packages
  • merge

@graphql-tools/merge

Table of contents

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:15

Variables

schemaDefSymbol

Const schemaDefSymbol: "SCHEMA_DEF_SYMBOL"

Defined in

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

Functions

applyExtensions

applyExtensions(schema, extensions): GraphQLSchema

Parameters

NameType
schemaGraphQLSchema
extensionsSchemaExtensions

Returns

GraphQLSchema

Defined in

packages/merge/src/extensions.ts:20


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:6


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:19


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:105


mergeDirectives

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

Parameters

NameTypeDefault value
d1readonly DirectiveNode[][]
d2readonly DirectiveNode[][]
config?Configundefined

Returns

DirectiveNode[]

Defined in

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


mergeEnum

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

Parameters

NameType
e1EnumTypeDefinitionNode | EnumTypeExtensionNode
e2EnumTypeDefinitionNode | EnumTypeExtensionNode
config?Config

Returns

EnumTypeDefinitionNode | EnumTypeExtensionNode

Defined in

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


mergeEnumValues

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

Parameters

NameType
firstundefined | readonly EnumValueDefinitionNode[]
secondundefined | readonly EnumValueDefinitionNode[]
config?Config

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:5


mergeFields

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

Type parameters

NameType
Textends FieldDefinitionNode | InputValueDefinitionNode

Parameters

NameType
typeObject
type.nameNameNode
f1undefined | readonly T[]
f2undefined | readonly T[]
config?Config

Returns

T[]

Defined in

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


mergeGraphQLNodes

mergeGraphQLNodes(nodes, config?): MergedResultMap

Parameters

NameType
nodesreadonly DefinitionNode[]
config?Config

Returns

MergedResultMap

Defined in

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


mergeGraphQLTypes

mergeGraphQLTypes(typeSource, config): DefinitionNode[]

Parameters

NameType
typeSourceTypeSource
configConfig

Returns

DefinitionNode[]

Defined in

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


mergeInputType

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

Parameters

NameType
nodeInputObjectTypeDefinitionNode | InputObjectTypeExtensionNode
existingNodeInputObjectTypeDefinitionNode | InputObjectTypeExtensionNode
config?Config

Returns

InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode

Defined in

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


mergeInterface

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

Parameters

NameType
nodeInterfaceTypeDefinitionNode | InterfaceTypeExtensionNode
existingNodeInterfaceTypeDefinitionNode | InterfaceTypeExtensionNode
config?Config

Returns

InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode

Defined in

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


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, Record<string, any>, any> | Maybe<IResolvers<TSource, TContext, Record<string, any>, any>>[]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?): ScalarTypeDefinitionNode | ScalarTypeExtensionNode

Parameters

NameType
nodeScalarTypeDefinitionNode | ScalarTypeExtensionNode
existingNodeScalarTypeDefinitionNode | ScalarTypeExtensionNode
config?Config

Returns

ScalarTypeDefinitionNode | ScalarTypeExtensionNode

Defined in

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


mergeType

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

Parameters

NameType
nodeObjectTypeDefinitionNode | ObjectTypeExtensionNode
existingNodeObjectTypeDefinitionNode | ObjectTypeExtensionNode
config?Config

Returns

ObjectTypeDefinitionNode | ObjectTypeExtensionNode

Defined in

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


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:84

mergeTypeDefs(typeSource, config?): string

Parameters

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

Returns

string

Defined in

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

mergeTypeDefs(typeSource, config?): DocumentNode

Parameters

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

Returns

DocumentNode

Defined in

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


mergeUnion

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

Parameters

NameType
firstUnionTypeDefinitionNode | UnionTypeExtensionNode
secondUnionTypeDefinitionNode | UnionTypeExtensionNode
config?Config

Returns

UnionTypeDefinitionNode | UnionTypeExtensionNode

Defined in

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


printTypeNode

printTypeNode(type): string

Parameters

NameType
typeTypeNode

Returns

string

Defined in

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