Provides GraphQL scalars for JavaScript's new Temporal specification.
You need a Temporal-compatible JavaScript environment or a polyfill to use this package.
You can find available polyfills here. See the test's polyfill for an installation example.
$ npm install graphql-temporal
Using graphql
package:
import { GraphQLZonedDateTime } from "graphql-temporal";
const schema = new GraphQLSchema({
ZonedDateTime: GraphQLZonedDateTime,
});
Using Apollo server:
import { GraphQLZonedDateTime } from "graphql-temporal";
const server = new ApolloServer({
typeDefs: ["scalar ZonedDateTime"],
resolvers: {
ZonedDateTime: GraphQLZonedDateTime,
},
});
An Instant
represents a fixed point in time (called "exact time"), without regard to calendar or location.
Maps to a Temporal.Instant
in your resolvers.
Example serialized string: 2020-01-01T12:30:00Z
A ZonedDateTime
is a timezone-aware, calendar-aware date/time object that represents a real event that has happened (or will happen) at a particular exact time from the perspective of a particular region on Earth.
Maps to a Temporal.ZonedDateTime
in your resolvers.
Example serialized string: 2020-01-01T12:30:00+10:00[Australia/Brisbane]
A PlainDate
object represents a calendar date that is not associated with a particular time or time zone.
Maps to a Temporal.PlainDate
in your resolvers.
Example serialized string: 2020-01-01
A PlainTime
represents a wall-clock time, with a precision in nanoseconds, and without any time zone.
Maps to a Temporal.PlainTime
in your resolvers.
Example serialized string: 12:30:00
A PlainDateTime
represents a calendar date and wall-clock time that does not carry time zone information.
Maps to a Temporal.PlainDateTime
in your resolvers.
Example serialized string: 2020-01-01T12:30:00
A Duration
represents a duration of time which can be used in date/time arithmetic.
Maps to a Temporal.Duration
in your resolvers.
Example serialized string: P2M