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

Can't pass multiple mutation inputs in variables #70

Open
haines opened this issue Jul 23, 2020 · 1 comment · May be fixed by #71
Open

Can't pass multiple mutation inputs in variables #70

haines opened this issue Jul 23, 2020 · 1 comment · May be fixed by #71
Labels
NeedsFix The path to resolution is known, but the work has not been done.

Comments

@haines
Copy link
Contributor

haines commented Jul 23, 2020

To do multiple mutations in a single request, it seems like you have to arbitrarily choose one of them to receive $input, and pass that input in the input argument to Mutate, while the other mutations have their inputs in variables.

I attempted to put both inputs in variables leaving input as nil, but this segfaults:

var mutation struct {
	MarkPullRequestReadyForReview struct {
		ClientMutationID string
	} `graphql:"markPullRequestReadyForReview(input: $markPullRequestReadyForReviewInput)"`
	AddAssigneesToAssignable struct {
		ClientMutationID string
	} `graphql:"addAssigneesToAssignable(input: $addAssigneesToAssignableInput)"`
}

variables := map[string]interface{}{
	"markPullRequestReadyForReviewInput": githubv4.MarkPullRequestReadyForReviewInput{
		PullRequestID: pullRequestID,
	},
	"addAssigneesToAssignableInput": githubv4.AddAssigneesToAssignableInput{
		AssignableID: pullRequestID,
		AssigneeIDs:  []githubv4.ID{assigneeID},
	},
}

err := c.githubv4.Mutate(context.Background(), &mutation, nil, variables)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x98 pc=0x7f4126]

goroutine 21 [running]:
github.com/shurcooL/graphql.writeArgumentType(0xd38800, 0xc00048e4b0, 0x0, 0x0, 0xc00013e001)
  /go/pkg/mod/github.com/shurcoo!l/graphql@v0.0.0-20181231061246-d48a9a75455f/query.go:58 +0x26
github.com/shurcooL/graphql.queryArguments(0xc00048e3f0, 0xc0005ae500, 0xc000632000)
  /go/pkg/mod/github.com/shurcoo!l/graphql@v0.0.0-20181231061246-d48a9a75455f/query.go:46 +0x368
github.com/shurcooL/graphql.constructMutation(0xa23fa0, 0xc0005ae500, 0xc00048e3f0, 0x7f93d5f3cfe8, 0x0)
  /go/pkg/mod/github.com/shurcoo!l/graphql@v0.0.0-20181231061246-d48a9a75455f/query.go:24 +0x76
github.com/shurcooL/graphql.(*Client).do(0xc0000a4b80, 0xd44980, 0xc000126010, 0x1, 0xa23fa0, 0xc0005ae500, 0xc00048e3f0, 0x0, 0x0)
  /go/pkg/mod/github.com/shurcoo!l/graphql@v0.0.0-20181231061246-d48a9a75455f/graphql.go:54 +0x696
github.com/shurcooL/graphql.(*Client).Mutate(...)
  /go/pkg/mod/github.com/shurcoo!l/graphql@v0.0.0-20181231061246-d48a9a75455f/graphql.go:44
github.com/shurcooL/githubv4.(*Client).Mutate(0xc0000a8110, 0xd44980, 0xc000126010, 0xa23fa0, 0xc0005ae500, 0x0, 0x0, 0xc00048e3f0, 0x0, 0x0)
  /go/pkg/mod/github.com/shurcoo!l/githubv4@v0.0.0-20200627185320-e003124d66e4/githubv4.go:55 +0xcc

I think it'd make sense to allow input to be nil if variables is given.

@haines haines linked a pull request Jul 23, 2020 that will close this issue
@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label May 22, 2022
@vpanta
Copy link

vpanta commented Sep 30, 2022

I dunno if it is a good enough fix, but looking at that prospective PR it seems pretty simple. Any chance it can get escalated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Development

Successfully merging a pull request may close this issue.

3 participants