cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Expect disruption to service on Thursday, Feb. 9!

Query for nodes that are not connected to a node with a specific property

livitowns
Node

Hi there,

I'm running into an issue that I can not seem te resolve. I have a neo4j database with "Document" nodes, some of which have a relationship with "Annotation" nodes. When a user creates annotations for a Document node, an Annotation node is created and connected to the Document node. I want to query for Document nodes that do not have Annotation nodes associated to the current annotator. In order to archieve this I wrote a query as such:

query {
  documents(
    where: { annotations_NONE: { annotator: "annotatorNameHere" } }
  ) {
  ...
  }
}

My problem is that this will only retrieve the Document nodes that have annotations that are not made by the current user, but not the Document nodes that don't have any relationships to Annotation nodes at all yet. I've been able to query for unannoted Document nodes like this:

query {
  documents(
    where: { annotationsAggregate: { count: 0 } }
  ) {
  ...
  }
}

but I have been unable to combine the two in one query.

Is this something that can be done? can I configure my type definitions somehow so that field_NONE will also match onto nodes that don't have relationships yet?

Thanks in advance!

0 REPLIES 0