offering forward compatibility - optionally ignoring unknown fields #3674
nick-stephen
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi team,
We have a situation where we can have a newer GraphQL client that is trying to talk to an older server.
The newer client would like to query newer fields in the GraphQL schema which are not (yet) present on the server.
On the server side we ensure schema backward compatibility by only allowing nullable fields to be added to a type, so it would be OK for the client to get back a null value in this situation, but the GraphQL validation phase fails.
This is often called a 'forward-compatibility' problem.
We're using graphql-yoga which uses envelop. Would it be possible / reasonable to create a plugin in either layer that checks an external condition (an extension field in the request, or possibly an http header) and, if the client requests it, remove unknown fields from the request before continuing with the normal full validation and execution of the request?
Doing this would allow some level of forward-compatibility support in GraphQL when this plugin was enabled.
The only current alternative I'm aware of is to have the client use a __type query to detect which fields exist in a schema, and then use different queries based upon version, this is pretty painful for the client.
Many thanks
Beta Was this translation helpful? Give feedback.
All reactions