0.0.2 • Published 6 years ago

graphql-phone-type v0.0.2

Weekly downloads
10
License
MIT
Repository
github
Last release
6 years ago

graphql-phone-type

GraphQL schema scalar phone type, based on libphonenumber-js.

Installation

npm i -S graphql-phone-type

or with Yarn:

yarn add graphql-phone-type

Usage

import { GraphQLObjectType, GraphQLSchema } from 'graphql'
import GraphQLPhoneType from 'graphql-phone-type'

export default new GraphQLSchema({
  query: new GraphQLObjectType({
    name: 'Query',
    fields: () => ({
      mobilePhone: {
        type: new GraphQLPhoneType({
          name: 'MobilePhone',
          country: 'RU',
          type: 'MOBILE'
        }),
        resolve: () => '+7 (915) 000 00 00',
      },
    }),
  }),
})

Then you can query it like this:

query {
  mobilePhone
}

Demo

An example GraphQL server implementation is available here: demo