Open ryankauk opened 4 years ago
hmm... fragments are merged/deduplicated in graphql, and it seems that graphql-code-generator
doesn't handle that itself it seems.
fragment f on PlanetsConnection {
planets {
name
orbitalPeriod
}
}
{
allPlanets {
planets {
name
id
}
planets {
name # Luckily an alias like `name: gravity` makes this query invalid
}
...f
}
}
yields
{
"data": {
"allPlanets": {
"planets": [
{
"name": "Tatooine",
"id": "cGxhbmV0czox",
"orbitalPeriod": 304
}, ...
fragment merging turns out to be a nightmare with the current design. I might try and accommodate this at some point, but for now you'll have to just make an intermediate fragment
On the document that's using the fragment, the generated dart creates the get/set methods howeveer they throw an error. For example...
Maybe the selection set classes that are generated from fragments template should all be mixins that are implemented on the documents that use them. Example scenario: _fragment.gql
GetModel.gql