updateSingleSelectFieldOptions updates a single-select field's options
(ctx context.Context, fieldID string, options []singleSelectOption, verbose bool)
| 784 | |
| 785 | // updateSingleSelectFieldOptions updates a single-select field's options |
| 786 | func 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 | } |
no test coverage detected