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

Allow building mutations from maps instead of structs #80

Open
grihabor opened this issue Nov 9, 2021 · 0 comments
Open

Allow building mutations from maps instead of structs #80

grihabor opened this issue Nov 9, 2021 · 0 comments

Comments

@grihabor
Copy link

grihabor commented Nov 9, 2021

Suppose I can create user like this

mutation($login: String!) {
	createUser(login: $login) { login }
}
variables {
	"login": "grihabor"
}

Now I'd like to create multiple users in single request

mutation($login1: String!, $login2: String!, $login3: String!) {
	createUser(login: $login1) { login }
	createUser(login: $login2) { login }
	createUser(login: $login3) { login }
}
variables {
	"login1": "grihabor",
        "login2": "diman",
        "login3": "indigo",
}

It would be convenient to implement it in code with ordered map

type CreateUser struct {
	Login graphql.String
}
m := [][2]interface{}{
	{"createUser(login: $login1)", &CreateUser{}},
	{"createUser(login: $login2)", &CreateUser{}},
	{"createUser(login: $login3)", &CreateUser{}},
}
variables := map[string]interface{}{
	"login1": "grihabor",
	"login2": "diman",
	"login3": "indigo",
}
_ = client.Mutate(context.Background(), &m, variables)

jfyi I've started implementing the thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant