Exclude null values from GraphQL query
Disclaimer, I am still a noob in GraphQL.
Apologies for the long post, but I need to give as much information as possible to explain my issue.
I am currently trying to query my Neo4j using GraphQL and then tabulate the data using ReTool.
I managed to do most of the work but when I query the database, I also get the null values.
You can access the sandbox below to test yourself a probable solution. https://codesandbox.io/s/great-marco-coy3k
The query I am using is the following:
query {
people{
child{
firstname{
name
}
middlename{
name
}
lastname{
name
}
phone{
name
}
email{
name
}
dob{
name
}
eid{
name
}
}
}
}
As you can see, I get back a mixture of null and none-null values.
What I would like to get back is the children that has data in them and ignore the null ones. The reason for that is when I try to populate my table, the null values appear there too.
I need to stress on the fact that I'd still need to retrieve "child" even if one or more of the objects are null as depicted in the image below:
While doing some research, I noticed that other people have the same problem I am facing (example), but most replies said there is no direct solution to this problem, many talked about adjusting the resolver which I am not sure how to do. The resolver file was already set by Neo4j Sandbox automatically and I don't know how to adjust it.
To provide more information regarding the root cause of the problem, you can check the Neo4j schema below:
As you can see, the two-person nodes that have the relationship MASTER_OF and CHILD_OF are similar. When I query people{child{firstname name}...}
I get the value of the node that has a IN CHILD_OF relationship and null for the node that has IN MASTER_OF relationship.
from Recent Questions - Stack Overflow https://ift.tt/3sKe6ue
https://ift.tt/3pxM0Re
Comments
Post a Comment