graphql-go / graphql-go/graphql
Array of Input / Mutation
- Dominant language
- Go
- Stars
- 10.1k
- Forks
- 845
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I got a question. I tried since hours to achieve to following:
Let's assume, we got an Object called User.
```
input User {
id int
name string
}
```
What I want to get is the possibility. to bind "User" to an array like [User] as an input and also have User available as Object,
Comming from node.js that was possible.
But how this will work with your lib? Is this even possible? I Can only add 1 Input-Type of this name, resolving either as list or as object, but not both, because the name "UserInput" was already registered.
Like this:
(This is just how I would do it in node.js)
```
mutation saveUser has inputObject of type User returning Bool
saveUser(input: User): Boolean
and mutation saveUsers has inputObject of type []User returning Bool
saveUsers(input: [User]): Boolean
```
Some go-code:
```
var UserIdInput = graphql.NewInputObject(graphql.InputObjectConfig{
Name: "UserInput",
Fields: graphql.InputObjectConfigFieldMap{
"id": &graphql.InputObjectFieldConfig{
Type: graphql.NewNonNull(graphql.Int),
},
"name": &graphql.InputObjectFieldConfig{
Type: graphql.NewNonNull(graphql.String),
},
},
})
var USERINPUT = map[string]graphql.Input{
"UserInput": UserInput,
// I know I can do: graphql.newList(UserInput), but I want both be possible for that inputtype
}
```
Contributor guide
Assessment
This issue has not been assessed yet.