Files
genqlient/generate/testdata/queries/StructOption.graphql
T
Ben KraftandGitHub 5211442843 Add a new option to treat an interface like an object (#97)
## Summary:
The basic idea here is if you only request interface fields (no
fragments) you may not care about the concrete type, and so we could
just generate a struct as if it were an object.  I don't think it's a
good idea to do that by default, because then if you later add a
fragment all your code totally changes, but it's quite reasonable as an
option!

Most of the code involved is just wiring and validation; the
core implementation is literally just: treat it like an object.

Issue: https://github.com/Khan/genqlient/issues/85

## Test plan:
make check


Author: benjaminjkraft

Reviewers: csilvers, StevenACoffman, benjaminjkraft, aberkan, dnerdy, jvoll, mahtabsabet, MiguelCastillo

Required Reviewers: 

Approved By: StevenACoffman

Checks:  Test (1.17),  Test (1.16),  Test (1.15),  Test (1.14),  Lint,  Test (1.17),  Test (1.16),  Test (1.15),  Test (1.14),  Lint

Pull Request URL: https://github.com/Khan/genqlient/pull/97
2021-09-15 18:00:22 -07:00

25 lines
373 B
GraphQL

fragment VideoFields on Video { duration }
# @genqlient(struct: true)
query StructOption {
root {
id
children {
id
parent {
id
children {
id
}
# (it won't apply to this)
interfaceChildren: children {
id
...VideoFields
}
}
}
}
# (nor this)
user { roles }
}