This is the main function that implements schema stitching. Note that in addition to the above arguments, the function also takes all the same arguments as
makeExecutableSchema. Read below for a description of each option.
subschemas is an array of
SubschemaConfig objects. These subschemas are wrapped with proxying resolvers in the final schema.
Additional types to add to the final type map, most useful for custom scalars or enums.
Strings or parsed documents that can contain additional types or type extensions. Note that type extensions are always applied last, while types are defined in the order in which they are provided.
resolvers accepts resolvers in same format as makeExecutableSchema. It can also take an Array of resolvers. One addition to the resolver format is the possibility to specify a
selectionSet for a resolver. The
selectionSet must be a GraphQL selection set definition string, specifying which fields from the parent schema are required for the resolver to function properly.
As described in the documentation above,
delegateToSchema allows delegating to any
SubschemaConfig object. Transforms do not have to be re-specified when passing a
SubschemaConfig object, which is the preserved workflow. Additional transforms can also be passed as needed. See Schema Delegation and the Using with transforms section of this document.
onTypeConflict option to
stitchSchemas allows customization of type resolving logic.
The default behavior of
stitchSchemas is to take the last encountered type of all the types with the same name, with a warning that type conflicts have been encountered. If specified,
onTypeConflict enables explicit selection of the winning type.
For example, here's how we could select the first type among multiple types with the same name:
And here's how we might select the type whose schema has the latest
When using schema transforms,
onTypeConflict is often unnecessary, since transforms can be used to prevent conflicts before merging schemas. However, if you're not using schema transforms,
onTypeConflict can be a quick way to make
stitchSchemas produce more desirable results.
inheritResolversFromInterfaces option is simply passed through to
addResolversToSchema, which is called when adding resolvers to the schema under the covers. See
addResolversToSchema for more info.