githubv4 icon indicating copy to clipboard operation
githubv4 copied to clipboard

Variable input of type MergePullRequestInput! was provided invalid value

Open ryboe opened this issue 6 years ago • 1 comments

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.

ryboe avatar Oct 15 '19 00:10 ryboe

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?

dmitshur avatar Oct 15 '19 14:10 dmitshur