Created
June 6, 2017 22:20
-
-
Save dmitry-saritasa/2d74315852128a1cc4af58e04ca2a638 to your computer and use it in GitHub Desktop.
GraphQL Fragments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test in : http://graphql.org/swapi-graphql | |
# --------------------------------------------- | |
# Fragment based query | |
# --------------------------------------------- | |
query details($episode: ID, $withStarship: Boolean = false) { | |
film(id: $episode) { | |
id | |
title | |
characterConnection { | |
characters { | |
id | |
name | |
starshipConnection { | |
starships { | |
...starshipDetails | |
} | |
} | |
} | |
} | |
starshipConnection @include(if: $withStarship) { | |
starships { | |
...starshipDetails | |
} | |
} | |
} | |
} | |
fragment starshipDetails on Starship { | |
id | |
name | |
pilotConnection { | |
pilots { | |
id | |
name | |
homeworld { | |
id | |
} | |
} | |
} | |
} | |
# Add below in variables section of graphiql | |
{ | |
"episode": "ZmlsbXM6MQ==", | |
"withStarship": true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment