graphql-go / graphql-go/graphql
GraphQl Response adding empty list for graphql.NewList type
- Dominant language
- Go
- Stars
- 10.1k
- Forks
- 845
- PR merge metrics
- No merged PRs in 30d
Description
We have graphql schema like below
Fan is a GraphQl object , which has a field called "ComposedOf" of type graphql.NewList. given below the snippet for refference.
VerSchema["Fan"].AddFieldConfig("ComposedOf", &graphql.Field{
Type: graphql.NewList(RelSchema["FanComposedOf"]),
Args: Arguments,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
ctx, _ := p.Context.Value("con").(map[string]interface{})
return arangodb.Expand(p.Source.(entity.GoEntity), "ComposedOf", ctx["dg"].(arangodb.DriverGateway), p.Args), nil
},
})
The arangodb.Expand() function returns empty interface{} object , when there is no data for type "ComposedOf" in the underlying database. Due to this in the Graphql Response, we are getting empty lists displyed as below
{
"ComposedOf":[],
"name": "Fan2",
"type": "Fan"
}
I am expecting this empty List should not come in response.
Contributor guide
Assessment
This issue has not been assessed yet.