What is schema stitching in GraphQL?
Answer
Schema stitching is the process of combining multiple separate GraphQL schemas into one unified schema. Implemented by the @graphql-tools/stitch library. It merges type definitions and resolvers from multiple schemas, enabling a gateway pattern where one GraphQL server aggregates several downstream services. Key features: type merging (combining the same type from multiple services), transforms (rename types/fields to avoid conflicts), remote schemas (proxy requests to remote GraphQL endpoints). Stitching differs from Federation: stitching is implemented in the gateway's Node.js code; Federation uses a spec-compliant protocol between services. Schema stitching is more flexible but requires more manual configuration. For new projects, Apollo Federation is generally preferred; stitching is still useful for integrating legacy or third-party GraphQL APIs.
More GraphQL Questions
View all →- Intermediate How do you implement pagination in GraphQL?
- Intermediate What is the Relay specification in GraphQL?
- Intermediate How do you implement authorization in GraphQL resolvers?
- Intermediate What is graphql-shield and how does it work?
- Intermediate How do you implement real-time subscriptions with GraphQL?