1.0.0 • Published 2 years ago

graphql-temporal v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

graphql-temporal

Provides GraphQL scalars for JavaScript's new Temporal specification.

Install

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

Usage

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,
  },
});

Scalars

Instant

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

ZonedDateTime

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]

PlainDate

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

PlainTime

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

PlainDateTime

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

Duration

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

1.0.0

2 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago