1

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
      }
    }
  }
}

Response

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:

The middlename is null which is completely fine

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:

Neo4j Schema

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.

1 Answer 1

1

As far as I understand, you are not sure what each value will return null : it may or it may not be null. In this case it is impossible to adjust your schema to only contain non-null values. You would have to deal with it in the frontend and completely exclude null values there.

Sign up to request clarification or add additional context in comments.

1 Comment

You're correct. I have some child which are completely null. And some which have some of their objects as null. Finding a backend solution is impossible. So as you've mentioned, I found a way to solve it in the frontend.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.