Variable input of type MergePullRequestInput! was provided invalid value
var m struct {
MergePullRequest struct {
PullRequest struct {
ID githubv4.ID
}
} `graphql:"mergePullRequest(input:$input)"`
}
squash := githubv4.PullRequestMergeMethodSquash
input := githubv4.MergePullRequestInput{
PullRequestID: githubv4.ID(prID),
MergeMethod: &squash, // <<<<<<<<<<<<<<<
}
...
err := c.client.Mutate(ctx, &m, input, nil)
fmt.Println(err)
Variable input of type MergePullRequestInput! was provided invalid value
MergeMethod is a *PullRequestMergeMethod. The values for PullRequestMergeMethod are all constants. I passed githubv4.PullRequestMergeMethodSquash the only way I know how, by copying the constant to a variable and then passing a pointer to the variable, but I got the error you see above. Am I doing something wrong?
I double-checked the GitHub settings for this repo and they do allow squash merging.
I don't see anything wrong in that snippet. Having to create a local variable when optional fields have constant enum values is unfortunate (and maybe should be improved, in a separate issue), but the way you've done it is fine and should produce expected results.
The problem may be elsewhere. Was there any more detail included in the error message?