teamwalnut / graphql-ppx

GraphQL language primitives for ReScript/ReasonML written in ReasonML
https://graphql-ppx.com
MIT License
257 stars 53 forks source link

Is there a way to ignore `__typename` when converting records using `ppxAs`? #252

Closed Pet3ris closed 3 years ago

Pet3ris commented 3 years ago

I'm migrating some code from @bsRecord to @ppxAs and running into an issue where the record types used in @ppxAs have to define __typename. Given __typename is a GraphQL internal field to disambiguate types, is there a way not to require this field in records?

  This record expression is expected to have type
    ReactHooksTemplate.Type.subType

  The field __typename does not belong to type ReactHooksTemplate.Type.subtype
Pet3ris commented 3 years ago

It seems like the __typename is still required even if I disable addTypename in the Apollo cache:

~cache=Cache.InMemoryCache.make(
    ~addTypename=false,
    ()
  )
Pet3ris commented 3 years ago

Fix thanks to @jfrolich:

Set:

"graphql": {
    "apolloMode": false,
    ...
}

in bsconfig.json.