Skip to content

Supporting backward compatible schemas #386

Open
@GFriedrich

Description

@GFriedrich

Is your feature request related to a problem? Please describe.
When making changes over time to a GraphQL schema, one of them might be adding a new type to an interface.
According to the GraphQL spec this is not considered a breaking change (see https://spec.graphql.org/October2021/#sec-Validation.Type-system-evolution):

Any change that can cause a previously valid request to become invalid is considered a breaking change.

As only a new type was added, all previous queries will still work.
graphql-js in turn "only" registers this as a "potentially dangerous change" (see https://github.com/graphql/graphql-js/blob/bb87e73067865207e19924297cabff45686f2a76/src/utilities/findBreakingChanges.ts#L62).

This all brings me to the conclusion that adding a new type to an existing interface should work also for genqlient.

Describe the solution you'd like
It would be great to allow the deserialization of responses using unknown types.
That could be achieved by using a default struct that just implements the common values of the interface and that is used as a fallback in case the type is unknown.
Optionally this behavior could be enabled/disabled depending on the use-case of the implementation.

Describe alternatives you've considered
The only other option would be to force people updating their applications which may become impossible/very cumbersome if there are a large number of service affected.

Additional context
None

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedIssues that anyone could pick up and implement if useful to them

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions