Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphql query to Fetch data between dates(_Neo4jLocalDateTime), #223

Closed
jithuprabhakaran opened this issue May 14, 2021 · 3 comments · Fixed by #235
Closed

Graphql query to Fetch data between dates(_Neo4jLocalDateTime), #223

jithuprabhakaran opened this issue May 14, 2021 · 3 comments · Fixed by #235

Comments

@jithuprabhakaran
Copy link

How can we write a Graphql query to fetch data between 2 different dates.? Date property that we use has datatype _Neo4jLocalDateTime.

@rbramley
Copy link
Contributor

This is related to #93 - the response states that "This type of filtering for temporal types is not yet implemented and there is currently no workaround to get it working."

However, it is possible to workaround it (with an obvious drawback around field selection) by declaring a custom @cypher query in your schema e.g.

movieDateFiltered(after: _Neo4jDateInput, before: _Neo4jDateInput): [Movie] @cypher(
statement: "MATCH (m:Movie) WHERE m.pub_date >= date(after) AND m.pub_date <= date(before) RETURN { title: m.title, pub_date: m.pub_date }")

And then query as:

query { 
  movieDateFiltered(
    after: {year:2016, month:12, day:31},
    before: {year:2020, month:1, day:1}
  )
  {
    title
    pub_date { formatted }
  }
}

I've used _Neo4jDate for simplicity, but you should be able to extend the same approach for datetimes.

@jithuprabhakaran
Copy link
Author

jithuprabhakaran commented May 21, 2021 via email

@rbramley
Copy link
Contributor

rbramley commented May 21, 2021

Hi @jithuprabhakaran,

If you're on Java 11 and happy to compile a 1.3.1-SNAPSHOT build, I've made a pull request for an initial implementation of date/time filtering.
As @Andy2003 has pointed out, the _Neo4jDateInput type et al will be refactored out as part of the API alignment effort with neo4j-graphql-js - so that PR is highly unlikely to be merged.

If you're on Java 8, I've got a variant of that PR that I'm trialling, but it's on a branch created from the 1.2.1(-SNAPSHOT) codebase of 25th March 2021 / commit 0f89393 before the update to Neo4j 4.2. I've not yet pushed that to my fork though.

Andy2003 added a commit that referenced this issue Jun 11, 2021
With these changes a new configuration param `useTemporalScalars` was introduced. With this configuration enabled, neo4js' temporales like `Date`, `Time`, `LocalTime`, `DateTime` and `LocalDateTime` are used as scalars (strings).

resolves #223, #109, #108, #93
Andy2003 added a commit that referenced this issue Jun 12, 2021
With these changes a new configuration param `useTemporalScalars` was introduced. With this configuration enabled, neo4js' temporales like `Date`, `Time`, `LocalTime`, `DateTime` and `LocalDateTime` are used as scalars (strings).

resolves #223
resolves #109
resolves #108
resolves #93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants