Additional GraphQL types
npm install graphql-type-factory> Additional GraphQL types
Install the package.
```
npm i --save graphql-type-factory
Use new types as you would use the default GraphQL types.
`js`
import { ... } from 'graphql-type-factory'; // ES6
var GraphQLTypeFactory = require('graphql-type-factory'); // CommonJS
#### ::: String Factory
`true
GraphQLStringFactory({
name: ... Type name.
min: ... Minimum string length.
max: ... Maximum string length.
regex: ... Regular expression pattern.
fn: ... Method which returns when input is valid.`
});
Example:
`js`
var NameType = GraphQLStringFactory({
name: 'Name',
fn: function(ast) {return ast.value.length > 5}
});
``
GraphQLEmailType
#### ::: URL
``
GraphQLURLType
How to run the example:
* Clone this repository.
* Run npm install to install the required modules.npm run example
* Run to start the GraphQL server.`
* Create a new user.`
curl -XPOST -H 'Content-Type:application/graphql' -d 'mutation RootMutation { addUser(id: "1", name: "John", email: "me@domain.com", website: "http://domain.com")}' http://localhost:4444`
* Retrieve created users.``
curl -XPOST -H 'Content-Type:application/graphql' -d '{users{id, email}}' http://localhost:4444