Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature idea] Remove __typename requirement from writeFragment #2987

Closed
lorensr opened this issue Feb 10, 2018 · 3 comments
Closed

[Feature idea] Remove __typename requirement from writeFragment #2987

lorensr opened this issue Feb 10, 2018 · 3 comments

Comments

@lorensr
Copy link
Contributor

lorensr commented Feb 10, 2018

client.writeFragment({
  id: '5',
  fragment: gql`
    fragment myTodo on Todo {
      completed
      __typename
    }
  `,
  data: {
    completed: true,
    __typename: 'Todo'
  },
});

It would be nice if I didn't have to include __typename in the fragment and __typename: 'Todo' in the data. Could it default to not writing __typename, or using the existing __typename?

@Poincare Poincare added the idea label Feb 19, 2018
@Poincare
Copy link
Contributor

I guess we could just addTypename the fragment to get rid of the first part of the issue. This sounds like a good idea to me. @jbaxleyiii , thoughts?

@alex996
Copy link

alex996 commented May 16, 2018

Furthermore, I don't understand how the docs suggest using writeFragment without __typename. Unless I include it, I end up with console warnings, whether I explicitly set addTypename in InMemoryCache to true or not (which it should be by default...):

You're using fragments in your queries, but either don't have the addTypename: true option set in Apollo Client, or you are trying to write a fragment to the store without the __typename. Please turn on the addTypename option and include __typename when writing fragments so that Apollo Client can accurately match fragments.

@hwillson
Copy link
Member

hwillson commented Jul 27, 2018

To help provide a more clear separation between feature requests / discussions and bugs, and to help clean up the feature request / discussion backlog, Apollo Client feature requests / discussions are now being managed under the https://github.com/apollographql/apollo-feature-requests repository.

Migrated to: apollographql/apollo-feature-requests#21

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants