Skip to content

Conversation

knpwrs
Copy link
Contributor

@knpwrs knpwrs commented Jan 1, 2019

This PR adds __typename to the query to show that union types can still be differentiated on the client and adds a second example showing common fields being queried in one spot.

There is another way to accomplish the same thing that I pointed out in this PR using fragments. Ultimately I felt like the solution targeting the common interface was cleaner and adding a note about Fragments might feel cluttered, but we can add this example if desired as well:

{
  search(text: "an") {
    __typename
    ... on Human {
      ...CharacterProps
      height
    }
    ... on Droid {
      ...CharacterProps
      primaryFunction
    }
    ... on Starship {
      name
      length
    }
  }
}

fragment CharacterProps on Character {
  name
}

Add `__typename` to the query to show that union types can still be differentiated on the client and add a second example showing common fields being queried in one spot.
# { "graphiql": true}
{
search(text: "an") {
__typename
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add something to the text regarding this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stubailo That should be all set now.

@stubailo
Copy link
Contributor

stubailo commented Jan 3, 2019

Thanks!

@stubailo stubailo merged commit c0cc5e1 into graphql:source Jan 3, 2019
@knpwrs knpwrs deleted the patch-1 branch January 4, 2019 00:29
Dipeshwagle pushed a commit to Dipeshwagle/graphql.github.io that referenced this pull request Aug 18, 2020
* Update Learn-Schema.md

Add `__typename` to the query to show that union types can still be differentiated on the client and add a second example showing common fields being queried in one spot.

* Add note about the use of `__typename`
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.

3 participants