graphql
graphql copied to clipboard
null filter on non-nullable one-to-one relationship opposite to expected
Type definitions with non-nullable one-to-one relationships:
type Movie {
title: String
released: Int
actors: Actor! @relationship(type: "ACTED_IN", direction: IN)
}
type Actor {
name: String
movies: Movie! @relationship(type: "ACTED_IN", direction: OUT)
}
Query:
query Movies {
movies(where: { released: 2003, actors: null }) {
title
}
}
Currently generated Cypher:
MATCH (this:Movie)
OPTIONAL MATCH (this)<-[:ACTED_IN]-(this0:Actor)
WITH *, count(this0) AS actorsCount
WITH *
WHERE (this.released = $param0 AND actorsCount <> 0)
RETURN this { .title } AS this
cypher params: { param0: Integer { low: 2003, high: 0 } }
NOTE notice the <> 0
in the above.
I would expect something closer to the case when the type definitions are updated to make them nullable one-to-one relationships. Same query.
MATCH (this:Movie)
WHERE (this.released = $param0 AND NOT (EXISTS {
MATCH (this)<-[:ACTED_IN]-(this0:Actor)
}))
RETURN this { .title } AS this
cypher params: { param0: Integer { low: 2003, high: 0 } }