https://github.com/homoky/graphql-timezone
Timezone scalar type for GraphQL.js.
https://github.com/homoky/graphql-timezone
Last synced: 6 months ago
JSON representation
Timezone scalar type for GraphQL.js.
- Host: GitHub
- URL: https://github.com/homoky/graphql-timezone
- Owner: homoky
- Created: 2020-09-10T15:11:20.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-11T09:00:51.000Z (over 5 years ago)
- Last Synced: 2024-11-11T16:09:19.313Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 27.3 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
- awesome-list - graphql-timezone
README
# GraphQL Timezone
Timezone scalar type for GraphQL.js.
Ex: `Europe/Prague`
## Usage
This package exports a Timezone scalar GraphQL.js type and list of available timezones as array of strings and as enum as well:
```
import timezoneScalar, { timezones, Timezone } from 'graphql-timezone';
// Generate Timezone scalar
const Timezone = timezoneScalar();
// Generate Timezone with custom name and custom description
const CustomTimezone = timezoneScalar({
name: 'CustomTimezone',
description: 'Description of Custom Timezone scalar.'
});
// Get list of avaliable timezones
const listOfAvailableTimezones: string[] = timezones;
// Use Enum of generated timezones
const newTimezone = Timezone.EuropePrague // Points to "Europe/Prague"
```
## Dependency
To list and validate the timezone, this library uses [MomentTimezone](https://momentjs.com/timezone/docs/).