99designs / 99designs/gqlgen

Arrays in changesets blow up with interface conversion error

Open
#3,657 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
10.8k
Forks
1.3k
Avg merge
2d 36m
Merged PRs (30d)
26

Description

I'm trying to follow the [changeset](https://gqlgen.com/reference/changesets/) tutorial, but my API is defined with arrays of inputs instead of just single objects, and this causes the generated code to blow up with the following error:

`interface conversion: interface {} is []interface {}, not map[string]interface {}`

The same thing happens if there's an array in the input object.

Here's the schema:
```
type Mutation {
test(input: [TestInput!]!): String
}

input TestInput {
name: String
}
```

I've got this in `gqlgen.yml`:
```
models:
TestInput:
model: "map[string]interface{}"
```

And this is the query I'm trying to run:
```
mutation test {
test(input: [
{
name: "banana"
}
])
}
```

Arrays as arguments to mutations work fine as long as I don't try to create changesets. I suspect the generator doesn't account for the possibility of arrays, unless I'm missing something about how to define this in `gqlgen.yml`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.