Skip to content

Override field types option for mergeSchemas #2051

@FluorescentHallucinogen

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 and uses @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.

graphql-voyager-visual-diff

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew addition or enhancement to existing solutions

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions