99designs / 99designs/gqlgen

Arrays in changesets blow up with interface conversion error

Aperta
#3,657 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
10.8k
Fork
1.3k
Merge medio
2g 36m
PR unite (30g)
26

Descrizione

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`.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.