Khan / Khan/genqlient

Option to use struct for a fragment

Open
#106 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
1.3k
Forks
143
Avg merge
4h 50m
Merged PRs (30d)
1

Description

With #85 we added support to say, if some field is of GraphQL interface type, but you don't request any type-specific fields, you can ask us to generate a struct instead. This would also be useful for fragments: suppose you have
```graphql
fragment A on MyInterface { ... }
fragment B on Impl1 {
...A
otherField1
}
fragment C on Impl2 {
...A
otherField2
}
query Q {
getImpl1 { ...B }
getImpl2 { ...C }
}
```
You want to be able to request extra fields on each implementation, but then write a function accepting the shared fields, as a struct. Ideally you could just put `# genqlient(struct: true)` on `A`, and then it would all work (subject to the constraint, here satisfied, that it's only spread into concrete types (or interface types with `struct: true`).

Contributor guide

Open the contributing guide

Research direction

Start by reviewing issue #85 and tracing how the existing interface `struct: true` option is represented for generated fragments. Define the fragment behavior described here, including spreads into concrete types or interfaces with `struct: true`, and verify that shared fields can be used as a struct alongside implementation-specific fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, graphql
Domain
api, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.