-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Support singular Project Issue Field updates #2941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zwick
wants to merge
3
commits into
veralizeth/mcp-batch-bulk-field-value
Choose a base branch
from
zwick-add-issue-field-resolution
base: veralizeth/mcp-batch-bulk-field-value
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1263,6 +1263,27 @@ type IssueFieldCreateOrUpdateInput struct { | |
| Suggest *githubv4.Boolean `json:"suggest,omitempty"` | ||
| } | ||
|
|
||
| type setIssueFieldValueMutation struct { | ||
| SetIssueFieldValue struct { | ||
| Issue struct { | ||
| ID githubv4.ID | ||
| URL githubv4.String | ||
| } | ||
| } `graphql:"setIssueFieldValue(input: $input)"` | ||
| } | ||
|
|
||
| // SetIssueFieldValues updates Issue Field values and returns the updated issue. | ||
| func SetIssueFieldValues(ctx context.Context, gqlClient *githubv4.Client, input SetIssueFieldValueInput) (MinimalResponse, error) { | ||
| var mutation setIssueFieldValueMutation | ||
| if err := gqlClient.Mutate(ctx, &mutation, input, nil); err != nil { | ||
| return MinimalResponse{}, err | ||
| } | ||
| return MinimalResponse{ | ||
| ID: fmt.Sprintf("%v", mutation.SetIssueFieldValue.Issue.ID), | ||
| URL: string(mutation.SetIssueFieldValue.Issue.URL), | ||
| }, nil | ||
| } | ||
|
|
||
| // GranularSetIssueFields creates a tool to set issue field values on an issue using GraphQL. | ||
| func GranularSetIssueFields(t translations.TranslationHelperFunc) inventory.ServerTool { | ||
| st := NewTool( | ||
|
|
@@ -1486,31 +1507,6 @@ func GranularSetIssueFields(t translations.TranslationHelperFunc) inventory.Serv | |
| return ghErrors.NewGitHubGraphQLErrorResponse(ctx, "failed to get issue", err), nil, nil | ||
| } | ||
|
|
||
| // Execute the setIssueFieldValue mutation | ||
| var mutation struct { | ||
| SetIssueFieldValue struct { | ||
| Issue struct { | ||
| ID githubv4.ID | ||
| Number githubv4.Int | ||
| URL githubv4.String | ||
| } | ||
| IssueFieldValues []struct { | ||
| TextValue struct { | ||
| Value string | ||
| } `graphql:"... on IssueFieldTextValue"` | ||
| SingleSelectValue struct { | ||
| Name string | ||
| } `graphql:"... on IssueFieldSingleSelectValue"` | ||
| DateValue struct { | ||
| Value string | ||
| } `graphql:"... on IssueFieldDateValue"` | ||
| NumberValue struct { | ||
| Value float64 | ||
| } `graphql:"... on IssueFieldNumberValue"` | ||
| } | ||
| } `graphql:"setIssueFieldValue(input: $input)"` | ||
| } | ||
|
|
||
| mutationInput := SetIssueFieldValueInput{ | ||
| IssueID: issueID, | ||
| IssueFields: issueFields, | ||
|
|
@@ -1519,14 +1515,12 @@ func GranularSetIssueFields(t translations.TranslationHelperFunc) inventory.Serv | |
| // The rationale and suggest input fields on IssueFieldCreateOrUpdateInput | ||
| // are gated behind the update_issue_suggestions GraphQL feature flag. | ||
| ctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, "update_issue_suggestions") | ||
| if err := gqlClient.Mutate(ctxWithFeatures, &mutation, mutationInput, nil); err != nil { | ||
| response, err := SetIssueFieldValues(ctxWithFeatures, gqlClient, mutationInput) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if err != nil { | ||
| return ghErrors.NewGitHubGraphQLErrorResponse(ctx, "failed to set issue field values", err), nil, nil | ||
| } | ||
|
|
||
| r, err := json.Marshal(MinimalResponse{ | ||
| ID: fmt.Sprintf("%v", mutation.SetIssueFieldValue.Issue.ID), | ||
| URL: string(mutation.SetIssueFieldValue.Issue.URL), | ||
| }) | ||
| r, err := json.Marshal(response) | ||
| if err != nil { | ||
| return utils.NewToolResultErrorFromErr("failed to marshal response", err), nil, nil | ||
| } | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only
id/urlare used.SetIssueFieldValuesreturns MinimalResponse{ID, URL}, so the extra IssueFieldValues selections were dead weight. Replacing it with a simpler type.