The object itself inside the object is parsed with an empty field.
input:
{
Products(search: {limit: 1, filters: {product_id: {gte: 5}}}) {
data {
product_id
product_name
sales_history{
total_check
}
}
}
}
output:
{
"data": {
"Products": {
"data": [
{
"product_id": 35,
"product_name": "testpr",
"sales_history": {}
}
]
}
}
}
Product type:
gql.ProductType = graphql.NewObject(graphql.ObjectConfig{
Name: "Product",
Fields: graphql.Fields{
"product_id": &graphql.Field{
Type: graphql.Int,
},
"product_name": &graphql.Field{
Type: graphql.String,
},
"sales_history": &graphql.Field{
Type: gql.SalesHistoryType,
},
},
})
SalesHistory type:
gql.SalesHistoryType = graphql.NewObject(graphql.ObjectConfig{
Name: "sales_history",
Fields: graphql.Fields{
"total_check": &graphql.Field{
Type: graphql.Float,
},
},
})
In Resolve returning map in interface:
map[data:[map[product_id:35 product_name:testpr sales_history:map[total_check:671.20]]]]
I create the map"sales_history" myself, otherwise opposite the field sales_history - null
The problem was in the packaging of the final map.
It was wrong:
*Some fields are hidden
That`s right: