Apollo-client: Make addTypename a default transform

Created on 2 Sep 2016  路  3Comments  路  Source: apollographql/apollo-client

Having the __typename on the client is really useful, and every spec-compliant GraphQL server is supposed to support this feature. I think we should turn on this transformation by default.

This might even let us build in features that rely on the __typename being present.

Most helpful comment

@stubailo There is just one big issue with this. When we serialize the data coming with typenames by default, mutate it via some client action e.g. using redux-form, then send it back, we still have the typenames inside the data. As our queries do not contain typenames, this fails. What is the suggest approach for fixing this? Disabling "addTypename" or adding typenames to each query?

All 3 comments

@stubailo There is just one big issue with this. When we serialize the data coming with typenames by default, mutate it via some client action e.g. using redux-form, then send it back, we still have the typenames inside the data. As our queries do not contain typenames, this fails. What is the suggest approach for fixing this? Disabling "addTypename" or adding typenames to each query?

@swernerx if you don't use fragments, you can disable addTypename, but the easiest and most certain fix is probably to add __typename manually for the time being.

Was this page helpful?
0 / 5 - 0 ratings