Skip to content

Can't pass multiple mutation inputs in variables #70

@haines

Description

@haines

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/[email protected]/query.go:58 +0x26
github.com/shurcooL/graphql.queryArguments(0xc00048e3f0, 0xc0005ae500, 0xc000632000)
  /go/pkg/mod/github.com/shurcoo!l/[email protected]/query.go:46 +0x368
github.com/shurcooL/graphql.constructMutation(0xa23fa0, 0xc0005ae500, 0xc00048e3f0, 0x7f93d5f3cfe8, 0x0)
  /go/pkg/mod/github.com/shurcoo!l/[email protected]/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/[email protected]/graphql.go:54 +0x696
github.com/shurcooL/graphql.(*Client).Mutate(...)
  /go/pkg/mod/github.com/shurcoo!l/[email protected]/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/[email protected]/githubv4.go:55 +0xcc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions