graphql icon indicating copy to clipboard operation
graphql copied to clipboard

Add INCLUDES-SOME, -ALL, -NONE and -SINGLE filter for scalar-arrays fields

Open Andy2003 opened this issue 2 years ago • 1 comments

Given the following schema:

type Movie {
  id: ID
  test: [String!]
}

the following additional where-fields should get generated:

input MovieWhere {
  test_INCLUDES_SOME: [String!]
  test_INCLUDES_ALL: [String!]
  test_INCLUDES_NONE: [String!]
  test_INCLUDES_SINGLE: [String!]

 // already existing filters
  test: [String!]
  test_NOT: [String!]

  test_INCLUDES: String @deprecated(reason : "Use `test_INCLUDES_SOME` instead.")
  test_NOT_INCLUDES: String @deprecated(reason : "Use `test_INCLUDES_NONE` instead.")

 // rest of the where fields ...
}

The following cypher will be generated:

INCLUDES_SOME

... WHERE any(x IN movie.test WHERE x IN $param0) ...

INCLUDES_ALL

... WHERE all(x IN movie.test WHERE x IN $param0) ...

INCLUDES_NONE

... WHERE none(x IN movie.test WHERE x IN $param0) ...

INCLUDES_SINGLE

... WHERE single(x IN movie.test WHERE x IN $param0) ...

This would align array fields to be handled in the same way as relations.

the following fields can be marked deprecated or kept as convenience fields:

  • test_INCLUDES: String -> Use test_INCLUDES_SOME instead
  • test_NOT_INCLUDES: String Use test_INCLUDES_NONE instead

see also: https://github.com/neo4j-graphql/neo4j-graphql-java/pull/285

Andy2003 avatar Jan 16 '23 11:01 Andy2003