Add multi-select field support to gh project - #13947
Conversation
Adds read + write for ProjectV2 multi-select fields: - queries.go: ProjectV2MultiSelectField in the ProjectField union and ProjectV2ItemFieldMultiSelectValue in the item field-value union, with JSON export. - ResolveMultiSelectOptionIDs for name-based option resolution. - item-edit: --multi-select-option-ids and comma-separated --value. - field-create: MULTI_SELECT data type with --multi-select-options. Local input structs supply multiSelectOptionIds / multiSelectOptions since the vendored githubv4 lacks them.
| } `graphql:"clearProjectV2ItemFieldValue(input:$input)"` | ||
| } | ||
|
|
||
| // ProjectV2FieldValue is defined locally because the vendored githubv4 lacks multiSelectOptionIds. |
There was a problem hiding this comment.
Perhaps we could open a PR against the githubv4 package to fill this gap? This seems fine as an interim solution but we wouldn't want to maintain our own mapping that isn't available in the underlying package to keep surface areas consistent
| editItemCmd.Flags().Float64Var(&opts.number, "number", 0, "Number value for the field") | ||
| editItemCmd.Flags().StringVar(&opts.date, "date", "", "Date value for the field (YYYY-MM-DD)") | ||
| editItemCmd.Flags().StringVar(&opts.singleSelectOptionID, "single-select-option-id", "", "ID of the single select option value to set on the field") | ||
| editItemCmd.Flags().StringSliceVar(&opts.multiSelectOptionIDs, "multi-select-option-ids", nil, "IDs of the multi select option values to set on the field") |
There was a problem hiding this comment.
nit: passing thought, not sure if this PR is the appropriate place to address this feedback
Single Select vs Multi-Select are very similar, essentially enforcing a different number of Max Selected Options. As a user, the ergonomics would feel nicer if this was a single uniform flag instead of two different flags for the different data types
| // splitOptionNames splits a comma-separated --value into individual option names | ||
| // for multi-select fields, trimming surrounding spaces and dropping empties. | ||
| func splitOptionNames(value string) []string { | ||
| parts := strings.Split(value, ",") |
There was a problem hiding this comment.
Just to confirm: is a Comma disallowed from being included in an Option Name for multi-select values?
Adds support for Projects v2 multi-select fields to the project commands.
What's included:
gh project item-list --format jsongh project item-edit, either by option IDs with--multi-select-option-idsor by name with a comma-separated--valuegh project field-create --data-type MULTI_SELECT --multi-select-options "a,b,c"The GraphQL input structs are defined locally because the vendored githubv4 does not have the multi-select types yet.
Draft for now. Multi-select is not in the public GraphQL schema yet, so I am holding this until it goes GA.