GraphQL filtering and the new date types

javascript

(Geoff Thorpe) #1

We provide a GraphiQL interface to our users to enable them to query our nested data.
The interface is based on the neo4j-graphql-js library.

The recent updates to the library have given us OrderBy and the ability to use the new date/time fields.

Our users have identified two gaps with filtering:

  1. Filtering of nested data - the ability to restrict by the content of a field in related nodes.
  2. Filtering by date - the ability to restrict to a time interval - e.g. last week's updates.

Are there any plans to implement those features and/or any workarounds?

Thanks
Geoff


(William Lyon) #2

Hi @geoff.thorpe - I'm glad to hear you're using neo4j-graphql.js! Yes, both of these should be addressed when we add support for the filter parameter in neo4j-graphql.js. There is an ongoing discussion in this Github issue. Would you mind adding your use cases (ideally with examples) so we can be sure they are addressed when we add the feature?

As for a workaround, you could add a custom @cypher directive query to your schema that implements the date range / filtering logic. Something like:

Query {
    eventsInDateRange(begin: Date, end: Date): [Event] @cypher(statement: "MATCH (e:event) WHERE $begin < e.date < $end RETURN e")
}

There is more on the @cypher schema directives in the docs here.