graphql-go / graphql-go/graphql

GraphQl Response adding empty list for graphql.NewList type

Open
#336 0 comments 0 reactions 0 assignees View on GitHub
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

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.