Neo4j supports native temporal types as properties on nodes and relationships. These types include Date, DateTime, and LocalDateTime. With neo4j-graphql.js you can use these temporal types in your GraphQL schema. Just use them in your SDL type definitions.
Temporal Types In SDL
neo4j-graphql.js makes available the following temporal types for use in your GraphQL type definitions:
LocalDateTime. You can use the temporal types in a field definition in your GraphQL type like this:
Using Temporal Fields In Queries
Temporal types expose their date components (such as day, month, year, hour, etc) as fields, as well as a
formatted field which is the ISO 8601 string representation of the temporal value. The specific fields available vary depending on which temporal is used, but generally conform to those specified here. For example:
Temporal Query Arguments
As part of the schema augmentation process temporal input types are added to the schema and can be used as query arguments. For example, given the type definition:
the following query will be generated for the
and the type
_Neo4jDateInput added to the schema:
At query time, either specify the individual components (year, month, day, etc) or the
formatted field, which is the ISO 8601 representation. For example, to query for all movies with a release date of October 10th, 1992:
Using Temporal Fields In Mutations
As part of the schema augmentation process temporal input types are created and used for the auto-generated create, update, delete mutations using the type definitions specified for the GraphQL schema. These temporal input types also include fields for each component of the temporal type (day, month, year, hour, etc) as well as
formatted, the ISO 8601 representation. When used in a mutation, specify either the individual components or the
formatted field, but not both.
For example, this mutation:
is equivalent to this version, using the
formatted field instead
The input types for temporals generally correspond to the fields used for specifying temporal instants in Neo4j described here.
- Blog post: Using Native DateTime Types With GRANDstack - Leverage Neo4j’s Temporal Types In Your GraphQL Schema With neo4j-graphql.js