Khan / genqlient

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

Optional parameter made required #337

Closed nelsonjr closed 1 month ago

nelsonjr commented 1 month ago

Describe the bug

For queries that have string parameters that are not !, the generator creates it as string instead of *string, making it impossible to use it, for example, on pagination cursors.

To Reproduce

Generate this query:

query Test($after: String) {
  projects(after: $after) {
    nodes {
      id
    }
  }
}

Observe that the test is:

func Test(
    ctx_ context.Context,
    client_ graphql.Client,
    after string,
) (*TestResponse, error) {
 ...
}

Expected behavior

For this query, after must be: after *string

genqlient version

v0.7.0

benjaminjkraft commented 1 month ago

Thanks for the post -- there's a bunch more documentation of genqlient's handling of nullability (by default and config options) here: https://github.com/Khan/genqlient/blob/main/docs/operations.md#nullable-fields

nelsonjr commented 1 month ago

Thanks, Ben, for the pointers!