neo4j-graphql / neo4j-graphql-java

Neo4j Labs Project: Pure JVM translation for GraphQL queries and mutations to Neo4j's Cypher
Apache License 2.0
105 stars 49 forks source link

Filters should not be available on a `@cypher` directive field since they don't work #309

Open isstabb opened 11 months ago

isstabb commented 11 months ago

Describe the bug Filters should not be available on a @cypher directive field since they don't work.

Test Case

GraphQL schema

type Person {
  id: ID
  name: String @cypher(statement:"RETURN this.name")
  age(mult:Int=13) : [Int] @cypher(statement:"RETURN this.age * mult")
  friends: [Person] @cypher(statement:"MATCH (this)-[:KNOWS]-(o) RETURN o")
  data: UserData @cypher(statement: "MATCH (this)-[:CREATED_MAP]->(m:Map) WITH collect({id: m.id, name: m.name}) AS mapsCreated, this RETURN {firstName: this.firstName, lastName: this.lastName, organization: this.organization, mapsCreated: mapsCreated}", passThrough:true)
}
type Query {
  person : [Person]
  p2: [Person] @cypher(statement:"MATCH (p:Person) RETURN p")
  p3(name:String): Person @cypher(statement:"MATCH (p:Person) WHERE p.name = name RETURN p")
  getUser(userId: ID): UserData @cypher(statement: "MATCH (u:User{id: {userId}})-[:CREATED_MAP]->(m:Map) WITH collect({id: m.id, name: m.name}) AS mapsCreated, u RETURN {firstName: u.firstName, lastName: u.lastName, organization: u.organization, mapsCreated: mapsCreated}", passThrough:true)
}

GraphQL request

{ person { friends(filter: {name: "won't work"}) { id } }}

Expected cypher query

Validation error

Additional context It's unclear if it would even be possible to fix the root issue of the filters not working on cypher fields. On the one hand the statement in the cypher directive could be just about anything, how could a filter be injected? But on the other hand the type is known, so presumably it could be handled? In any case, at least until that could be fixed they should not be in the augmented schema.