Future Added Values
graphql-ppx
will add the polymorphic variant \
FutureAddedValue(value)` by
default to both enum fields & union variants. This is in accordance to the
graphql specification, in order to build robust clients against potentially
changing server schemas.
Lee Byron, the co-creator of graphql, says the following about this topic:
These are generated as a reminder that GraphQL services often expand in capabilities and may return new enum values. To be future-proof, clients should account for this possibility and do something reasonable to avoid a broken product.
Adding this variant is intentional default behaviour of the ppx, to avoid unintentional production bugs. You have however the option, to specifically opt-out of this behaviour and disable the generation of this additional variant. This could be useful, if you have absolute control over both the client and the server schema and are confident, that they may never be out of sync.
To opt-out, you can specify the option future_added_value: false
, either in
your bsconfig.json
(see config),
or directly on your query.
Example:
The second way is to use the directive @ppxOmitFutureValue
directly on your
queried field.
Please note: Decoding the raw query result while having the future value
variant disabled, can lead to a Not_found
exception being thrown if an
unexpected result is received.