genqlient icon indicating copy to clipboard operation
genqlient copied to clipboard

Add request and response cases for `Optional` values

Open Jictyvoo opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. Currently I'm using the Go default values for a response in a lot of fields. But currently I need to to send a pointer for optional values, and still receive the value as the response.

Describe the solution you'd like On the file genqlient.yaml have a new config that receives the option that will be used on optional on request, and another option on response.

Describe alternatives you've considered On the genqlient.yaml have the following alternatives:

optional:
    request: pointer
    response: value # use value as default if empty

Alternative

request:
    optional: pointer
    use_struct_references: true
response:
    optional: value
    use_struct_references: false

Jictyvoo avatar Dec 02 '22 15:12 Jictyvoo

Seems reasonable to me! As far as I can guess it should be easy enough to implement. (Although I won't likely have time soon, so PRs extra welcome!) I like the first config option.

benjaminjkraft avatar Dec 03 '22 02:12 benjaminjkraft