Khan / genqlient

a truly type-safe Go GraphQL client
MIT License
1.03k stars 99 forks source link

feat: always set omitempty on pointer fields #287

Closed obitech closed 5 months ago

obitech commented 12 months ago

When optional: "pointer" is configured, omitempty is needed for input fields for the generated code to be semantically correct. Without omitempty an empty pointer would generate an "empty value" which is incorrect.

Consider the following graphql schema generated by Hasura:

input task_insert_input {
  id: Int
}

Without this fix, the following golang struct will be generated:

type Task_insert_input struct {
  Id: *int `json:"id"`
}

I have:

justonia commented 9 months ago

What's the status on this? I'm working with the Linear API and it's broken if omitempty isn't supported.

staugaard commented 7 months ago

I'm also waiting for this feature.

benjaminjkraft commented 5 months ago

Closing in favor of #308 which uses a config option