Closed
Description
I'm trying to create a filter that says "where a list of relationships is non-empty". For example, loading a database with:
create(n1:Person {name:"foo"}),
(n2:Person {name:"bar"}),
(n3:Pet {name:"baz"}),
(n1)-[:knows]->(n2),
(n2)-[:knows]->(n3)
with the schema:
type Person {
name: String!
friends: [Person!]! @relation(name:"knows",direction:OUT)
pets: [Pet!] @relation(name:"knows",direction:OUT)
}
type Pet {
name: String!
}
I want a query that says "find me only the people that know
a Person
, regardless of whether or not they know
any Pet
s". Based on the filter documentation I was hoping to use something like:
{
person (filter: { friends_not: null }) {
name
friends {
name
}
pets {
name
}
}
}
but this produces the following error: Input for friends must be an filter-InputType
. I also tried a few different queries:
(filter: { friends: { name_not: null } })
- I was hoping this would work indirectly since it would match into the friend node and filter on the name, but that produced this cypher:MATCH (person:Person) WHERE ALL(person_Person_Cond IN [(person)-[:knows]->(person_Person) | (NOT person_Person.name = $filterPerson_PersonName)] WHERE person_Person_Cond) RETURN person { .name,friends:[(person)-[:knows]->(personFriends:Person) | personFriends { .name }],pets:[(person)-[:knows]->(personPets:Pet) | personPets { .name }] } AS person
- the
NOT person_Person.name = $filterPerson_PersonName
since$filterPerson_PersonName
isnull
the query does not get the expected results, and when I manually change it to anis null
, I also get the unexpected result of bothPerson
s.
(filter: { friends_not: [] })
- Input for friends must be an filter-InputType
I created nmonterroso/neo4j-graphql-java-filters to illustrate this issue.
Any help is greatly appreciated!
EDIT - This also affects the server plugin neo4j-graphql
, and I've created neo4j-graphql#177 for that side of the equation.
Metadata
Metadata
Assignees
Labels
No labels