graphql-iso-enums
v1.0.4
Published
Enum types in GraphQL for some ISO codes.
Downloads
20
Readme
graphql-iso-enums
Some GraphQL Enum Types to wrap some ISO Codes.
Installation
$ npm install --save graphql-iso-enums
Usage
Here are the currently available types:
import {
ISOUSState,
ISOTerritory,
ISOLanguage,
ISOCurrency
} from 'graphql-iso-enums'
Or, if you only want to load an individual type:
// get the GraphQL Enum Type
import { ISOTerritory } from 'graphql-iso-enums/types/ISOTerritory'
// get a plain object of the codes
import { CODES as territoryCodes } from 'graphql-iso-enums/types/ISOTerritory'
After adding the types to your schema, get the enum values (and human-readable forms) using an introspection query in GraphQL
query getLanguages {
__type(name: "ISO639_1") {
enumValues {
name
description
}
}
}
Note: The GraphQL type names are different than the exported property names.
Contributing
Got some other ISO code in your GraphQL API? Fork, modify, and put in a pull request! With your help, we can assemble one module that becomes the go-to for ISO codes in GraphQL!