Skip to main content

@graphql-tools/merge

Interfaces#

Type aliases#

Variables#

Functions#

Type aliases#

CompareFn#

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

Type parameters#

Name
T

Type declaration#

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

Parameters#

NameType
aT
bT

Returns: -1 | 0 | 1

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


EnumTypeExtensions#

Ƭ EnumTypeExtensions: object

Type declaration#

NameType
type"enum"
valuesRecord<string, ExtensionsObject\>

Defined in: packages/merge/src/extensions.ts:49


ExtensionsObject#

Ƭ ExtensionsObject: Record<string, any\>

Defined in: packages/merge/src/extensions.ts:24


InputTypeExtensions#

Ƭ InputTypeExtensions: object

Type declaration#

NameType
fieldsRecord<string, { extensions: ExtensionsObject }\>
type"input"

Defined in: packages/merge/src/extensions.ts:31


InterfaceTypeExtensions#

Ƭ InterfaceTypeExtensions: object

Type declaration#

NameType
fieldsRecord<string, { arguments: Record<string, ExtensionsObject\> ; extensions: ExtensionsObject }\>
type"interface"

Defined in: packages/merge/src/extensions.ts:36


MergedResultMap#

Ƭ MergedResultMap: Record<string, NamedDefinitionNode\> & { [schemaDefSymbol]: SchemaDefinitionNode | SchemaExtensionNode }

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


NamedDefinitionNode#

Ƭ NamedDefinitionNode: DefinitionNode & { name?: NameNode }

Defined in: packages/merge/src/typedefs-mergers/merge-nodes.ts:16


ObjectTypeExtensions#

Ƭ ObjectTypeExtensions: object

Type declaration#

NameType
fieldsRecord<string, { arguments: Record<string, ExtensionsObject\> ; extensions: ExtensionsObject }\>
type"object"

Defined in: packages/merge/src/extensions.ts:26


PossibleTypeExtensions#

Ƭ PossibleTypeExtensions: InputTypeExtensions | InterfaceTypeExtensions | ObjectTypeExtensions | UnionTypeExtensions | ScalarTypeExtensions | EnumTypeExtensions

Defined in: packages/merge/src/extensions.ts:54


ResolversDefinition#

Ƭ ResolversDefinition<TContext\>: IResolvers<any, TContext\> | ResolversFactory<TContext\>

Type parameters#

Name
TContext

Defined in: packages/merge/src/merge-resolvers.ts:4


ResolversFactory#

Ƭ ResolversFactory<TContext\>: (...args: any[]) => IResolvers<any, TContext\>

Type parameters#

Name
TContext

Type declaration#

▸ (...args: any[]): IResolvers<any, TContext\>

Parameters#

NameType
...argsany[]

Returns: IResolvers<any, TContext\>

Defined in: packages/merge/src/merge-resolvers.ts:3


ScalarTypeExtensions#

Ƭ ScalarTypeExtensions: object

Type declaration#

NameType
type"scalar"

Defined in: packages/merge/src/extensions.ts:45


SchemaExtensions#

Ƭ SchemaExtensions: object

Type declaration#

NameType
schemaExtensionsExtensionsObject
typesRecord<string, { extensions: ExtensionsObject } & PossibleTypeExtensions\>

Defined in: packages/merge/src/extensions.ts:61


UnionTypeExtensions#

Ƭ UnionTypeExtensions: object

Type declaration#

NameType
type"union"

Defined in: packages/merge/src/extensions.ts:41

Variables#

schemaDefSymbol#

Const schemaDefSymbol: typeof schemaDefSymbol

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

Functions#

applyExtensions#

applyExtensions(schema: GraphQLSchema, extensions: SchemaExtensions): GraphQLSchema

Parameters#

NameType
schemaGraphQLSchema
extensionsSchemaExtensions

Returns: GraphQLSchema

Defined in: packages/merge/src/extensions.ts:157


collectComment#

collectComment(node: NamedDefinitionNode): void

Parameters#

NameType
nodeNamedDefinitionNode

Returns: void

Defined in: packages/merge/src/typedefs-mergers/comments.ts:22


defaultStringComparator#

defaultStringComparator(a: string, b: string): CompareVal

Parameters#

NameType
astring
bstring

Returns: CompareVal

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


extractExtensionsFromSchema#

extractExtensionsFromSchema(schema: GraphQLSchema): SchemaExtensions

Parameters#

NameType
schemaGraphQLSchema

Returns: SchemaExtensions

Defined in: packages/merge/src/extensions.ts:198


extractType#

extractType(type: TypeNode): NamedTypeNode

Parameters#

NameType
typeTypeNode

Returns: NamedTypeNode

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


isListTypeNode#

isListTypeNode(type: TypeNode): type is ListTypeNode

Parameters#

NameType
typeTypeNode

Returns: type is ListTypeNode

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


isNamedDefinitionNode#

isNamedDefinitionNode(definitionNode: DefinitionNode): definitionNode is NamedDefinitionNode

Parameters#

NameType
definitionNodeDefinitionNode

Returns: definitionNode is NamedDefinitionNode

Defined in: packages/merge/src/typedefs-mergers/merge-nodes.ts:18


isNonNullTypeNode#

isNonNullTypeNode(type: TypeNode): type is NonNullTypeNode

Parameters#

NameType
typeTypeNode

Returns: type is NonNullTypeNode

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


isSourceTypes#

isSourceTypes(types: any): types is Source

Parameters#

NameType
typesany

Returns: types is Source

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


isStringTypes#

isStringTypes(types: any): types is string

Parameters#

NameType
typesany

Returns: types is string

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


isWrappingTypeNode#

isWrappingTypeNode(type: TypeNode): 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: InputValueDefinitionNode[], args2: InputValueDefinitionNode[], config: Config): InputValueDefinitionNode[]

Parameters#

NameType
args1InputValueDefinitionNode[]
args2InputValueDefinitionNode[]
configConfig

Returns: InputValueDefinitionNode[]

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


mergeDirective#

mergeDirective(node: DirectiveDefinitionNode, existingNode?: DirectiveDefinitionNode): DirectiveDefinitionNode

Parameters#

NameType
nodeDirectiveDefinitionNode
existingNode?DirectiveDefinitionNode

Returns: DirectiveDefinitionNode

Defined in: packages/merge/src/typedefs-mergers/directives.ts:99


mergeDirectives#

mergeDirectives(d1?: ReadonlyArray<DirectiveNode\>, d2?: ReadonlyArray<DirectiveNode\>, config?: Config): DirectiveNode[]

Parameters#

NameTypeDefault value
d1ReadonlyArray<DirectiveNode\>[]
d2ReadonlyArray<DirectiveNode\>[]
config?Config-

Returns: DirectiveNode[]

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


mergeEnum#

mergeEnum(e1: EnumTypeDefinitionNode | EnumTypeExtensionNode, e2: EnumTypeDefinitionNode | EnumTypeExtensionNode, config?: 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: ReadonlyArray<EnumValueDefinitionNode\>, second: ReadonlyArray<EnumValueDefinitionNode\>, config?: Config): EnumValueDefinitionNode[]

Parameters#

NameType
firstReadonlyArray<EnumValueDefinitionNode\>
secondReadonlyArray<EnumValueDefinitionNode\>
config?Config

Returns: EnumValueDefinitionNode[]

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


mergeExtensions#

mergeExtensions(extensions: SchemaExtensions[]): SchemaExtensions

Parameters#

NameType
extensionsSchemaExtensions[]

Returns: SchemaExtensions

Defined in: packages/merge/src/extensions.ts:142


mergeFields#

mergeFields<T\>(type: { name: NameNode }, f1: ReadonlyArray<T\>, f2: ReadonlyArray<T\>, config?: Config): T[]

Type parameters#

NameType
TFieldDefinitionNode | InputValueDefinitionNode

Parameters#

NameType
typeobject
type.nameNameNode
f1ReadonlyArray<T\>
f2ReadonlyArray<T\>
config?Config

Returns: T[]

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


mergeGraphQLNodes#

mergeGraphQLNodes(nodes: ReadonlyArray<DefinitionNode\>, config?: Config): MergedResultMap

Parameters#

NameType
nodesReadonlyArray<DefinitionNode\>
config?Config

Returns: MergedResultMap

Defined in: packages/merge/src/typedefs-mergers/merge-nodes.ts:24


mergeGraphQLTypes#

mergeGraphQLTypes(types: (string | Source | DocumentNode | GraphQLSchema)[], config: Config): DefinitionNode[]

Parameters#

NameType
types(string | Source | DocumentNode | GraphQLSchema)[]
configConfig

Returns: DefinitionNode[]

Defined in: packages/merge/src/typedefs-mergers/merge-typedefs.ts:141


mergeInputType#

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

Parameters#

NameType
nodeInputObjectTypeDefinitionNode | InputObjectTypeExtensionNode
existingNodeInputObjectTypeDefinitionNode | InputObjectTypeExtensionNode
config?Config

Returns: InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode

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


mergeInterface#

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

Parameters#

NameType
nodeInterfaceTypeDefinitionNode | InterfaceTypeExtensionNode
existingNodeInterfaceTypeDefinitionNode | InterfaceTypeExtensionNode
configConfig

Returns: InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode

Defined in: packages/merge/src/typedefs-mergers/interface.ts:6


mergeNamedTypeArray#

mergeNamedTypeArray(first?: ReadonlyArray<NamedTypeNode\>, second?: ReadonlyArray<NamedTypeNode\>, config?: Config): NamedTypeNode[]

Parameters#

NameTypeDefault value
firstReadonlyArray<NamedTypeNode\>[]
secondReadonlyArray<NamedTypeNode\>[]
configConfig{}

Returns: NamedTypeNode[]

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


mergeResolvers#

mergeResolvers<TContext, T\>(resolversDefinitions: T[], options?: MergeResolversOptions): T

Deep merges multiple resolver definition objects into a single definition.

Type parameters#

NameType
TContext-
TResolversDefinition<TContext\>

Parameters#

NameTypeDescription
resolversDefinitionsT[]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: T

Defined in: packages/merge/src/merge-resolvers.ts:42


mergeScalar#

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

Parameters#

NameType
nodeScalarTypeDefinitionNode | ScalarTypeExtensionNode
existingNodeScalarTypeDefinitionNode | ScalarTypeExtensionNode
config?Config

Returns: ScalarTypeDefinitionNode | ScalarTypeExtensionNode

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


mergeSchemas#

mergeSchemas(config: MergeSchemasConfig): GraphQLSchema

Synchronously merges multiple schemas, typeDefinitions and/or resolvers into a single schema.

Parameters#

NameTypeDescription
configMergeSchemasConfigConfiguration object

Returns: GraphQLSchema

Defined in: packages/merge/src/merge-schemas.ts:56


mergeSchemasAsync#

mergeSchemasAsync(config: MergeSchemasConfig): Promise<GraphQLSchema\>

Synchronously merges multiple schemas, typeDefinitions and/or resolvers into a single schema.

Parameters#

NameTypeDescription
configMergeSchemasConfigConfiguration object

Returns: Promise<GraphQLSchema\>

Defined in: packages/merge/src/merge-schemas.ts:76


mergeType#

mergeType(node: ObjectTypeDefinitionNode | ObjectTypeExtensionNode, existingNode: ObjectTypeDefinitionNode | ObjectTypeExtensionNode, config?: 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(types: (string | Source | DocumentNode | GraphQLSchema)[]): DocumentNode

Merges multiple type definitions into a single DocumentNode

Parameters#

NameTypeDescription
types(string | Source | DocumentNode | GraphQLSchema)[]The type definitions to be merged

Returns: DocumentNode

Defined in: packages/merge/src/typedefs-mergers/merge-typedefs.ts:79

mergeTypeDefs(types: (string | Source | DocumentNode | GraphQLSchema)[], config?: Partial<Config\> & { commentDescriptions: true }): string

Parameters#

NameType
types(string | Source | DocumentNode | GraphQLSchema)[]
config?Partial<Config\> & { commentDescriptions: true }

Returns: string

Defined in: packages/merge/src/typedefs-mergers/merge-typedefs.ts:80

mergeTypeDefs(types: (string | Source | DocumentNode | GraphQLSchema)[], config?: Omit<Partial<Config\>, "commentDescriptions"\>): DocumentNode

Parameters#

NameType
types(string | Source | DocumentNode | GraphQLSchema)[]
config?Omit<Partial<Config\>, "commentDescriptions"\>

Returns: DocumentNode

Defined in: packages/merge/src/typedefs-mergers/merge-typedefs.ts:84


mergeUnion#

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

Parameters#

NameType
firstUnionTypeDefinitionNode | UnionTypeExtensionNode
secondUnionTypeDefinitionNode | UnionTypeExtensionNode
config?Config

Returns: UnionTypeDefinitionNode | UnionTypeExtensionNode

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


printComment#

printComment(comment: string): string

Parameters#

NameType
commentstring

Returns: string

Defined in: packages/merge/src/typedefs-mergers/comments.ts:77


printTypeNode#

printTypeNode(type: TypeNode): string

Parameters#

NameType
typeTypeNode

Returns: string

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


printWithComments#

printWithComments(ast: ASTNode): any

Converts an AST into a string, using one set of reasonable formatting rules.

Parameters#

NameType
astASTNode

Returns: any

Defined in: packages/merge/src/typedefs-mergers/comments.ts:167


pushComment#

pushComment(node: any, entity: string, field?: string, argument?: string): void

Parameters#

NameType
nodeany
entitystring
field?string
argument?string

Returns: void

Defined in: packages/merge/src/typedefs-mergers/comments.ts:51


resetComments#

resetComments(): void

Returns: void

Defined in: packages/merge/src/typedefs-mergers/comments.ts:18


travelSchemaPossibleExtensions#

travelSchemaPossibleExtensions(schema: GraphQLSchema, hooks: { onEnum: (type: GraphQLEnumType) => any ; onEnumValue: (type: GraphQLEnumType, value: GraphQLEnumValue) => any ; onInputFieldType: (type: GraphQLInputObjectType, field: GraphQLInputField) => any ; onInputType: (type: GraphQLInputObjectType) => any ; onInterface: (type: GraphQLInterfaceType) => any ; onInterfaceField: (type: GraphQLInterfaceType, field: GraphQLField<any, any\>) => any ; onInterfaceFieldArg: (type: GraphQLInterfaceType, field: GraphQLField<any, any\>, arg: GraphQLArgument) => any ; onObjectField: (type: GraphQLObjectType, field: GraphQLField<any, any\>) => any ; onObjectFieldArg: (type: GraphQLObjectType, field: GraphQLField<any, any\>, arg: GraphQLArgument) => any ; onObjectType: (type: GraphQLObjectType) => any ; onScalar: (type: GraphQLScalarType) => any ; onSchema: (schema: GraphQLSchema) => any ; onUnion: (type: GraphQLUnionType) => any }): void

Parameters#

NameType
schemaGraphQLSchema
hooksobject
hooks.onEnum(type: GraphQLEnumType) => any
hooks.onEnumValue(type: GraphQLEnumType, value: GraphQLEnumValue) => any
hooks.onInputFieldType(type: GraphQLInputObjectType, field: GraphQLInputField) => any
hooks.onInputType(type: GraphQLInputObjectType) => any
hooks.onInterface(type: GraphQLInterfaceType) => any
hooks.onInterfaceField(type: GraphQLInterfaceType, field: GraphQLField<any, any\>) => any
hooks.onInterfaceFieldArg(type: GraphQLInterfaceType, field: GraphQLField<any, any\>, arg: GraphQLArgument) => any
hooks.onObjectField(type: GraphQLObjectType, field: GraphQLField<any, any\>) => any
hooks.onObjectFieldArg(type: GraphQLObjectType, field: GraphQLField<any, any\>, arg: GraphQLArgument) => any
hooks.onObjectType(type: GraphQLObjectType) => any
hooks.onScalar(type: GraphQLScalarType) => any
hooks.onSchema(schema: GraphQLSchema) => any
hooks.onUnion(type: GraphQLUnionType) => any

Returns: void

Defined in: packages/merge/src/extensions.ts:66