We are currently experiencing an issue in generating supergraph response from different subgraphs when field values are null. Consider below example -
Let’s assume we have two subgraphs: SubgraphA and SubgraphB.
SubgraphA defines MyEntity like this
type MyEntity @key(fields: “id”) {
id: Int!
propertyA: String!
}
SubgraphB defines MyEntity like this
type MyEntity @key(fields: “id”) {
id: Int!
propertyB: String!
}
Now if we try to run a query like below and data is not present in both subgraphs, we receive response with null data from two subgraphs as shown below -
Query -
{
myEntity {
id
propertyA # resolved from SubgraphA
propertyB # resolved from SubgraphB
}
}
Response -
{
“data” : {
“id” : 1
“propertyA” : null # resolved from SubgraphA
“propertyB” : null # resolved from SubgraphB
}
}
Here, in the above example, we discussed about single entity with two fields but in real scenario there might be list of entities with multiple null field values
In this case, Clients need to parse entire response for all the IDs to confirm if there exists any consumable data at all in the response.
We are looking for a guidance to handle such use cases and best practice to design such scenarios