graphql-ppx will add the polymorphic variant
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.
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
bsconfig.json (see config),
or directly on your query.
The second way is to use the directive
@ppxOmitFutureValue directly on your
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.