neo4j-graphql-java icon indicating copy to clipboard operation
neo4j-graphql-java copied to clipboard

Filter on nodes that are nested inside type relation is not working as expected

Open AakashSorathiya opened this issue 3 years ago • 4 comments

Filters on the node, which is defined under type relation in schema, are not working as expected. The cypher query that is generated is not correct.

Test Case

GraphQL schema

type Role @relation(name:"ACTED_IN", from:"actor", to:"movie") {
   actor: Person
   movie: Movie
   type: String
}
type Person {
  name: String
  born: Int
  roles: [Role]
}
type Movie {
  title: String
  released: Int
  characters: [Role]
}
type Query {
  person: [Person]
  movie: [Movie]
}

GraphQL request

{
  person(first: 30, roles: { movie_not: null, movie: { title_starts_with: "P" } }) {
    roles {
      movie {
        title
      }
      type
    }
    name
  }
}

Expected cypher query

MATCH (person:Person) WHERE ( EXISTS {MATCH (person)-[:ACTED_IN]->(:Movie)} AND all(personMovieCond IN [(person)-[:ACTED_IN]->(personMovie:Movie) | personMovie.title STARTS WITH $personMovieTitleStartsWith] WHERE personMovieCond)) RETURN person { roles: [(person)-[personRoles:ACTED_IN]->(personRolesMovie:Movie) | personRoles { movie: personRolesMovie { .title}, .type }], .name} AS person SKIP 0 LIMIT 30

Generated cypher query

MATCH (person:Person) WHERE all(personPersonRolesCond IN [(person)<-[:ACTED_IN]-(personPersonRoles:ACTED_IN) | (EXISTS { 		MATCH (personPersonRoles)-[:ACTED_IN]->(:Movie) } AND any(personPersonRolesMovieCond IN [(personPersonRoles)-[:ACTED_IN]->(personPersonRolesMovie:Movie) | personPersonRolesMovie.title STARTS WITH $personPersonRolesMovieTitleStartsWith] WHERE personPersonRolesMovieCond))] WHERE personPersonRolesCond) RETURN person { roles: [(person)-[personRoles:ACTED_IN]->(personRolesMovie:Movie) | personRoles { movie: personRolesMovie { .title }, .type }], .name} AS person SKIP 0 LIMIT 30

AakashSorathiya avatar Dec 05 '21 18:12 AakashSorathiya

I am currently working on a major refactoring regarding the API alignment with the JS version. This bug will also be fixed with the new API. There will be no fix for this issue for the current version.

Andy2003 avatar Mar 25 '22 13:03 Andy2003

Any Update on this ?

Eddy08 avatar Aug 09 '22 05:08 Eddy08

Any Update on this ?

work is still in progress

Andy2003 avatar Aug 17 '22 19:08 Andy2003

Any Update on this ?

work is still in progress

Hi @Andy2003, I have raised a PR(https://github.com/neo4j-graphql/neo4j-graphql-java/pull/272) for this bug fix. If you find the implementation proper it can be merged for now till you release the new version with API-Alignment. Also, if you need any help on the api alignment work I am ready to contribute.

AakashSorathiya avatar Aug 19 '22 10:08 AakashSorathiya