Support `optional: generic` inline
- Dominant language
- Go
- Stars
- 1.3k
- Forks
- 143
- Avg merge
- 4h 50m
- Merged PRs (30d)
- 1
Description
**Is your feature request related to a problem? Please describe.**
We now have support for mapping GraphQL optional types to generics (see #251). In many schemas, though, you don't want to deal with that everywhere; for example for some fields mapping to empty-string is clear enough and easier to use. We should allow flagging the generic for just certain fields.
**Describe the solution you'd like**
Probably the way to do this is to still put `optional_generic_type` in the `genqlient.yaml`, but omit `optional: generic` and then do that inline. We could also let you specify both inline, but I really hope you don't need that and requiring it would be very verbose.
**Describe alternatives you've considered**
As anyone who has used genqlient knows, I hate using pointers for optionality! But sometimes zero values don't cut it.
Contributor guide
Research direction
Start by reading the existing optional generic support from issue #251 and the optional_generic_type configuration in genqlient.yaml. Determine how an individual field can opt into generic mapping without repeating the configuration, and consider the inline syntax and its interaction with configuration; done means the requested schema fields generate generic optional types while other fields retain their existing mapping.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, graphql
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100