graphql-cypher icon indicating copy to clipboard operation
graphql-cypher copied to clipboard

Filtering and paginating on @cypherNode and @cypherRelationship

Open a-type opened this issue 5 years ago • 4 comments

Connecting directives need more control over how the data is queried.

Research:

  • [x] What clauses are allowed in list projections?

Implement:

  • [x] Matching based on arbitrary user defined parameters
  • [ ] ORDER BY / SKIP / LIMIT

Questions:

  • Is there any point to these directives, or could @cypher just be expanded to work in nested scenarios?

a-type avatar May 31 '19 21:05 a-type

Research results: only WHERE is allowed in list projections (https://github.com/opencypher/openCypher/issues/202).

Ordering, skipping, limiting will all be blocked on better sub-query support (https://github.com/opencypher/openCypher/pull/217), but if that gets added to the spec, the library will get a major feature boost!

A fake pagination could be introduced by slicing up the list comprehension, but it would not be lazy, and without ordering it doesn't feel very useful. List ordering currently unsupported (https://github.com/opencypher/openCypher/issues/190).

Alternate approach to achieving nested paginated fields: manually combine subqueries by chaining WITH blocks then pull them back into a final map projection (yikes!)... might end up doing it. Query perf might be worse due to eager operations, but I think that's going to be unavoidable if the schema uses pagination at each field level anyways.

a-type avatar Jun 01 '19 14:06 a-type

Next steps:

  • [x] Add WHERE clause support to @cypherNode and @cypherRelationship (#4)
  • [ ] Prototype allowing nested @cypher directives using WITH chaining

a-type avatar Jun 01 '19 14:06 a-type

This is marked as blocked. What is needed in order to implement this?

SpaghettiFactory avatar May 28 '20 12:05 SpaghettiFactory

Hi @SpaghettiFactory ! I admit this project isn't really on my radar anymore, but here's how I remember it -

Basically, without first-class subqueries, Cypher can't really support nested pagination. I don't quite remember the specifics, but I believe this library uses field projections to accomplish nested structures, and field projections don't allow for standard pagination constructs to be used (or at least, not to the extend that they could enable cursor-based pagination).

This issue was related, and is still open - https://github.com/opencypher/openCypher/pull/217

Limitations with Cypher for this use case in particular was, as I recall, why I ended up shopping around for different graph databases to use behind GraphQL. I had a bit of success with ArangoDB, which does support subqueries in its query language.

a-type avatar Jun 01 '20 01:06 a-type