The Guild LogoThe Guild Monogram

Search docs

Search icon

Products by The Guild


Hive logoHive blurred logo


Schema Registry for your GraphQL Workflows

GraphQL Tools

GraphQL Tools

A set of utilities for faster GraphQL development

Get Started

Stitching API#


This is the main function that implements schema stitching. It accepts all the same arguments as makeExecutableSchema, and the additions below.

import { stitchSchemas } from '@graphql-tools/stitch'; stitchSchemas({ subschemas?: Array<GraphQLSchema | SubschemaConfig | Array<SubschemaConfig>>; types?: Array<GraphQLNamedType>; typeDefs?: ITypeDefinitions; resolvers?: IResolvers<any, TContext> | Array<IResolvers<any, TContext>>; mergeDirectives?: boolean; mergeTypes?: boolean | Array<string> | MergeTypeFilter; typeMergingOptions?: TypeMergingOptions; onTypeConflict?: OnTypeConflict; subschemaConfigTransforms?: Array<SubschemaConfigTransform>; }): GraphQLSchema export interface TypeMergingOptions { typeDescriptionsMerger?: (candidates: Array<MergeTypeCandidate>) => string; fieldConfigMerger?: (candidates: Array<MergeFieldConfigCandidate>) => GraphQLFieldConfig<any, any>; inputFieldConfigMerger?: (candidates: Array<MergeInputFieldConfigCandidate>) => GraphQLInputFieldConfig; } export type OnTypeConflict = ( left: GraphQLNamedType, right: GraphQLNamedType, info?: { left: { subschema?: GraphQLSchema | SubschemaConfig; transformedSubschema?: Subschema; }; right: { subschema?: GraphQLSchema | SubschemaConfig; transformedSubschema?: Subschema; }; } ) => GraphQLNamedType;
  • subschemas: an array of schema-like objects. These subschemas are wrapped with proxying resolvers in the final schema.
  • types: additional types to add to the final type map, most useful for custom scalars or enums.
  • typeDefs: strings or parsed documents that contain additional types or type extensions. Type extensions are always applied last.
  • resolvers: accepts standard resolvers with the addition of specifying a selectionSet.
  • mergeTypes: specifies a strategy for handling duplicated types.
  • typeMergingOptions: allows customization of automatic type merging.
  • onTypeConflict: allows customization of manual type resolution.


Creates a merged type resolver that may be wrapped with custom behaviors.

import { createMergedTypeResolver } from '@graphql-tools/stitch'; createMergedTypeResolver({ fieldName?: string; args?: (originalResult: any) => Record<string, any>; argsFromKeys?: (keys: ReadonlyArray<K>) => Record<string, any>; valuesFromResults?: (results: any, keys: ReadonlyArray<K>) => Array<V>; }): MergedTypeResolver


Creates a dynamic selectionSet that forwards gateway arguments to a resolver selection hint.

import { forwardArgsToSelectionSet } from '@graphql-tools/stitch'; forwardArgsToSelectionSet( selectionSet: string, mapping?: Record<string, string[]> ) => (field: FieldNode) => SelectionSetNode