Skip to content
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

Variable input of type MergePullRequestInput! was provided invalid value #48

Open
ryboe opened this issue Oct 15, 2019 · 1 comment
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@ryboe
Copy link

ryboe commented Oct 15, 2019

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.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 15, 2019
@dmitshur
Copy link
Member

dmitshur commented Oct 15, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Development

No branches or pull requests

2 participants