MCPcopy Index your code
hub / github.com/github/gh-aw / updateSingleSelectFieldOptions

Function updateSingleSelectFieldOptions

pkg/cli/project_command.go:786–827  ·  view source on GitHub ↗

updateSingleSelectFieldOptions updates a single-select field's options

(ctx context.Context, fieldID string, options []singleSelectOption, verbose bool)

Source from the content-addressed store, hash-verified

784
785// updateSingleSelectFieldOptions updates a single-select field's options
786func updateSingleSelectFieldOptions(ctx context.Context, fieldID string, options []singleSelectOption, verbose bool) error {
787 projectLog.Print("Updating single-select field options")
788
789 mutation := `mutation($input: UpdateProjectV2FieldInput!) {
790 updateProjectV2Field(input: $input) {
791 projectV2Field {
792 ... on ProjectV2SingleSelectField {
793 name
794 options { name }
795 }
796 }
797 }
798 }`
799
800 variables := map[string]any{
801 "input": map[string]any{
802 "fieldId": fieldID,
803 "singleSelectOptions": options,
804 },
805 }
806
807 requestBody := map[string]any{
808 "query": mutation,
809 "variables": variables,
810 }
811
812 requestJSON, err := json.Marshal(requestBody)
813 if err != nil {
814 return fmt.Errorf("failed to marshal GraphQL request: %w", err)
815 }
816
817 // Use ExecGH to create command and pipe input
818 cmd := workflow.ExecGH("api", "graphql", "--input", "-")
819 cmd.Stdin = bytes.NewReader(requestJSON)
820
821 output, err := cmd.CombinedOutput()
822 if err != nil {
823 return fmt.Errorf("failed to update field options: %w\nOutput: %s", err, string(output))
824 }
825
826 return nil
827}

Callers 1

ensureStatusOptionFunction · 0.85

Calls 3

ExecGHFunction · 0.92
PrintMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected