-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Milestone
Description
Currently interface selections are inlined, this can lead to overly verbose/complex queries. fragments can be used to reduce the size of the query.
e.g.
query Hero($episode: Episode) {
hero(episode: $episode) {
id
name
friends {
id
name
... on Human {
homePlanet
height
mass
__typename
}
... on Droid {
primaryFunction
__typename
}
__typename
}
appearsIn
... on Human {
homePlanet
height
mass
appearsIn
starships {
id
name
length
coordinates
__typename
}
__typename
}
...Droid {
appearsIn
primaryFunction
__typename
}
__typename
}
}could be reduced to
query Hero($episode: Episode) {
hero(episode: $episode) {
id
name
friends {
id
name
...Human
...Droid
__typename
}
appearsIn
... Human
... on Droid
__typename
}
}
fragment Human on Human {
homePlanet
height
mass
__typename
}
fragment Droid on Droid {
appearsIn
primaryFunction
__typename
}Although at the final depth it wouldn't be able to use the fragment as it would add unnecessary depth
Metadata
Metadata
Assignees
Labels
No labels