ardatan / ardatan/graphql-tools
Override field types option for mergeSchemas
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 830
- Avg merge
- 10h 59m
- Merged PRs (30d)
- 45
Description
I'm working on a tool that shows a visual diff between two GraphQL schemas (e.g the previous and current versions of the same schema). Added fields are marked in green color, deleted in red and modified in yellow. It's built on top of [graphql-voyager](https://www.npmjs.com/package/graphql-voyager) and uses [@graphql-inspector/core](https://www.npmjs.com/package/@graphql-inspector/core) under the hood.
In order to display the deleted fields in Voyager I merge both schemas using `mergeSchemas` from `@graphql-tools/merge`.

The problem is that if e.g. `Post.content` in `schemaA` (the previous version of the schema) has the `String!` (non-null) type, but `Post.content` in `schemaB` (the current version of the schema) has the `String` (nullable) type, the `Post.content` in the result of `mergeSchemas` of `[schemaA, schemaB]` (in that order) will have the `String!` type (from the previous `schemaA`), not the `String` type (from the current `schemaB`). See the image below.
Could you please add an option for `mergeSchemas` that changes the behavior of merging non-null and nullable fields to use (override) the nullability from the latest schema from the array?
Contributor guide
Research direction
Start at mergeSchemas in @graphql-tools/merge and review how the schemaA and schemaB ordering currently determines field types. The requested option should make the later schema's nullability override the earlier schema's nullability, and completion should be demonstrated for the String! versus String example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100