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(gatsby): Add __typename and id fields in queries to match previous behavior of relay-compiler #20849

Merged
merged 2 commits into from
Jan 27, 2020

Conversation

vladar
Copy link
Contributor

@vladar vladar commented Jan 24, 2020

Description

We introduced an unintentional BC break in #19665 (when replaced Relay compiler with our own solution)

Before that PR relay compiler was adding extra fields to queries automatically:

  1. An id field if it existed on the type
  2. A __typename field if the type was a union or an interface.

In other words the following query:

{
  unionField {
    ... on TypeWithId {
      foo
    }
  }
}

was transformed to:

{
  unionField {
    __typename
    ... on TypeWithId {
      id
      foo
    }
  } 
}

Current PR mimics Relay compiler behavior and restores backwards compatibility.

Documentation

This "feature" is not documented and shouldn't be. It is not recommended to rely on it as it will be removed in Gatsby v3.0

Related Issues

Fixes #20290

@vladar vladar marked this pull request as ready for review January 24, 2020 19:20
@vladar vladar requested a review from a team as a code owner January 24, 2020 19:20
Copy link
Contributor

@freiksenet freiksenet left a comment

Choose a reason for hiding this comment

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

Begrudgingly accepted :D

@wardpeet wardpeet merged commit 4d27336 into master Jan 27, 2020
@wardpeet wardpeet deleted the vladar/gh-20290 branch January 27, 2020 08:36
@vladar
Copy link
Contributor Author

vladar commented Jan 28, 2020

Published in [email protected]

@afc163
Copy link
Contributor

afc163 commented Feb 4, 2020

#20943 (comment)

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.

__typename is not added automatically after relay-compiler was removed
4 participants