Khan / Khan/genqlient

Omitempty-style handling for array elements

Open
#44 1 comment 1 reaction 0 assignees View on GitHub
enhancement needs design needs use cases
Dominant language
Go
Stars
1.3k
Forks
143
Avg merge
4h 50m
Merged PRs (30d)
1

Description

Suppose you have an argument that's a `[String]!` and you want to pass `["a", null, "c"]`. Right now you pretty much have to do `pointer: true`, then pass `[]*string{&"a", null, &"c"}` (except of course that's not valid syntax, the real syntax is uglier until golang/go#45624). But we should be able to just let you apply the `omitempty` to the elements, instead of or in addition to to the whole array, so that you can pass `[]string{"a", "", "c"}` and it does the thing you mean. It may need a name since it's really "translate empty elements to null", rather than omitting them.

See also #16 and #14.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the requested behavior with related issues #16 and #14, then trace how omitempty is currently applied to array arguments. Define how empty string elements should become null without omitting the array, including the naming decision, and verify the behavior for ["a", "", "c"].

Written by the indexing model from the issue text.

Assessment

Tech stack
go, graphql
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.