You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A panic occurs when attempting to pass a null value from a query variable that maps to a GraphQL list that can contain null elements (e.g. with an enum Status, the input is [Status]).
Notably this only happens when the query arguments are passed separately as variables and not when they are passed inline with the graphql document.
I.e.
queryTodos($status: [Status]) {
todos(status: $status) {
id
}
}
package gqlgen
import (
"context"
) // THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.typeResolverstruct{}
func (r*Resolver) Query() QueryResolver {
return&queryResolver{r}
}
typequeryResolverstruct{ *Resolver }
func (r*queryResolver) Todos(ctx context.Context, filter []*Status) ([]*Todo, error) {
returnnil, nil
}
gqlgen.yml
# .gqlgen.yml example## Refer to https://gqlgen.com/config/# for detailed .gqlgen.yml documentation.schema:
- schema.graphqlexec:
filename: generated.gomodel:
filename: models_gen.goresolver:
filename: resolver.gotype: Resolverautobind: []
What happened?
A panic occurs when attempting to pass a
null
value from a query variable that maps to a GraphQL list that can contain null elements (e.g. with an enumStatus
, the input is[Status]
).Notably this only happens when the query arguments are passed separately as variables and not when they are passed inline with the graphql document.
I.e.
With query arguments:
panics, but:
does not.
Panic stacktrace:
What did you expect?
The value is correctly decoded as
nil
.Minimal graphql.schema and models to reproduce
schema.graphql
resolver.go
gqlgen.yml
Used with test server from
gqlgen init
.Example curl:
versions
v0.10.1
go version go1.13.4 linux/amd64
The text was updated successfully, but these errors were encountered: