Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/enniel/graphql-phone-type
https://github.com/enniel/graphql-phone-type
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/enniel/graphql-phone-type
- Owner: enniel
- Created: 2017-12-05T09:14:52.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-27T15:43:20.000Z (over 2 years ago)
- Last Synced: 2024-10-08T13:26:49.196Z (3 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graphql-phone-type
GraphQL schema scalar phone type, based on [libphonenumber-js](https://github.com/catamphetamine/libphonenumber-js).
## Installation
```bash
npm i -S graphql-phone-type
```or with Yarn:
```bash
yarn add graphql-phone-type
```## Usage
```js
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:
```graphql
query {
mobilePhone
}
```## Demo
An example GraphQL server implementation is available here:
[demo](https://github.com/enniel/graphql-phone-type/tree/master/demo)