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

Fix __typename addition for InlineFragments #1286

Merged
merged 4 commits into from
May 21, 2019

Conversation

trevor-scheer
Copy link
Member

@trevor-scheer trevor-scheer commented May 20, 2019

We need operation registration (client:push) __typename
adding to match how Apollo Client does this in order for query
hashes to match.

In order to achieve parity here, I've added the __typename field
to InlineFragments as well. While the __typename on an interface
may be redundant (see new tests for example), it's also a safer
change for me to recommend than anything within Apollo Client.

TODO:

  • Update CHANGELOG.md* with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

*Make sure changelog entries note which project(s) has been affected. See older entries for examples on what this looks like.

We need operation registration's __typename adding to match how
Apollo Client does this in order for query hashes to match.

In order to achieve parity here, I've added the __typename field
to InlineFragments as well. While the __typename on an interface
may be redundant (see new tests for example), it's also a safer
change for me to recommend than anything within Apollo Client.
@shehaaz
Copy link

shehaaz commented May 21, 2019

Thank you for the quick fix @trevor-scheer! Will this me approved and merged today? :)

Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change itself looks great to me. 😄

packages/apollo-language-server/src/utilities/graphql.ts Outdated Show resolved Hide resolved
@trevor-scheer trevor-scheer merged commit f4a5c8d into master May 21, 2019
@trevor-scheer trevor-scheer deleted the trevor/fix-missing-typenames branch May 21, 2019 18:49
hwillson added a commit that referenced this pull request Nov 9, 2021
The `withTypenameFieldAddedWhereNeeded` utility in `apollo-language-server`
was updated in #1286 to make sure `__typename`'s are added to inline
fragments, when used by commands like `client:push`. The
`apollo-codegen-core` package currently uses its own copy of
`withTypenameFieldAddedWhereNeeded` however, which was not updated. This
means that operations can be registered (in Apollo's operation registry)
via `client:push` that don't line up with the operations output by codegen.

This commit adjusts the `apollo-codegen-core` package to use the same
`withTypenameFieldAddedWhereNeeded` function as `apollo-language-server`
(which is already a dependency of codegen), to make sure the operations
output from codegen line up with the operations pushed via
`client:push`.
hwillson added a commit that referenced this pull request Nov 9, 2021
The `withTypenameFieldAddedWhereNeeded` utility in `apollo-language-server`
was updated in #1286 to make sure `__typename`'s are added to inline
fragments, when used by commands like `client:push`. The
`apollo-codegen-core` package currently uses its own copy of
`withTypenameFieldAddedWhereNeeded` however, which was not updated. This
means that operations can be registered (in Apollo's operation registry)
via `client:push` that don't line up with the operations output by codegen.

This commit adjusts the `apollo-codegen-core` package to use the same
`withTypenameFieldAddedWhereNeeded` function as `apollo-language-server`
(which is already a dependency of codegen), to make sure the operations
output from codegen line up with the operations pushed via
`client:push`.
hwillson added a commit that referenced this pull request Nov 9, 2021
The `withTypenameFieldAddedWhereNeeded` utility in `apollo-language-server`
was updated in #1286 to make sure `__typename`'s are added to inline
fragments, when used by commands like `client:push`. The
`apollo-codegen-core` package currently uses its own copy of
`withTypenameFieldAddedWhereNeeded` however, which was not updated. This
means that operations can be registered (in Apollo's operation registry)
via `client:push` that don't line up with the operations output by codegen.

This commit adjusts the `apollo-codegen-core` package to use the same
`withTypenameFieldAddedWhereNeeded` function as `apollo-language-server`
(which is already a dependency of codegen), to make sure the operations
output from codegen line up with the operations pushed via
`client:push`.
hwillson added a commit that referenced this pull request Nov 11, 2021
The `withTypenameFieldAddedWhereNeeded` utility in `apollo-language-server`
was updated in #1286 to make sure `__typename`'s are added to inline
fragments, when used by commands like `client:push`. The
`apollo-codegen-core` package currently uses its own copy of
`withTypenameFieldAddedWhereNeeded` however, which was not updated. This
means that operations can be registered (in Apollo's operation registry)
via `client:push` that don't line up with the operations output by codegen.

This commit adjusts the `apollo-codegen-core` package to use the same
`withTypenameFieldAddedWhereNeeded` function as `apollo-language-server`
(which is already a dependency of codegen), to make sure the operations
output from codegen line up with the operations pushed via
`client:push`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants