graphql-iso-enums

1.0.4 • Public • Published

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!

Package Sidebar

Install

npm i graphql-iso-enums

Weekly Downloads

10

Version

1.0.4

License

MIT

Last publish

Collaborators

  • acarl005