Apollo query polymorphic totality

Maybe a question specific for @jeddeloh but I notice that its easy to write a graphql query that doesn’t request all the possible types that may be returned for a polymorphic field, and when one of those unexpected ones does come back the type parsing code crashes.

So. is there a way to know when im missing pulling down types? or alternatively have the value be optional?

Thanks
Alex

I might need an example to understand what you’re asking. By “polymorphic field” are you referring to Unions and Enums? rescript-apollo-client isn’t much more than a wrapper for graphql-ppx. If you’re able to write an unsafe query the question is probably better directed there, but let’s see if that’s the case.

:wave:

I have this mutation:

        result {
          ... on TypeCapability { id }
          ... on ErrorMessage { message }
        }

If instead I give

        result {
          ... on TypeCapability { id }
        }

but query returns an ErrorMessage…

Maybe for graphql-ppx youre right.

lol, i may have been down this road before: More verbose Errors for partial unions than "Not_found" · Issue #286 · teamwalnut/graphql-ppx · GitHub

1 Like

Okay, yeah. I graphql-ppx is the right place to follow up on that

1 Like