Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Latest commit 6425e9a May 2, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test Ser interface types (#10) Mar 6, 2019
.gitignore first commit Nov 19, 2018
.travis.yml Add travisCi and Coveralls (#3) Dec 28, 2018
LICENSE Add readme Nov 19, 2018
README.MD Set deprecated field and read json schema (#7) Feb 1, 2019
index.js first commit Nov 19, 2018
logo.png Update logo Nov 22, 2018
package-lock.json 0.0.9 May 2, 2019
package.json

README.MD

EasyGraphQL Mock
easygraphql-parser

Coverage Status Greenkeeper badge

easygraphql-parser is a node library used to parse the GraphQL schema into a JS object.

Installation

$ npm install easygraphql-parser --save

Usage

To get started with the mocks, you might need to follow the next steps:

Schema

type Family {
  name: String!
  ages: [Int!]!
}

type Query {
  getFamily: Family
}

Parser

'use strict'

const fs = require('fs')
const path = require('path')
const easygraphqlSchemaParser = require('easygraphql-parser')

const schemaCode = fs.readFileSync(path.join(__dirname, 'schema', 'schema.gql'), 'utf8')

const schema = easygraphqlSchemaParser(schemaCode)
console.log(schema)

Result

{ 
  Family: { 
    type: 'ObjectType',
    description: undefined,
    fields: [ 
      { 
        name: 'name',
        arguments: [],
        noNull: true,
        isArray: false,
        noNullArrayValues: false
        type: 'String',
        isDeprecated: false
      },
      { 
        name: 'ages',
        arguments: [],
        noNull: true,
        isArray: true,
        noNullArrayValues: true
        type: 'Int',
        isDeprecated: false
      } 
    ],
    values: [] 
  },
  Query: { 
    type: 'ObjectType',
    description: undefined,
    fields:  [ 
      { 
        name: 'getFamily',
        arguments: [],
        noNull: false,
        isArray: false,
        noNullArrayValues: false
        type: 'Family',
        isDeprecated: false
      } 
    ],
    values: [] 
  } 
}

License

The MIT License

Copyright (c) 2018 EasyGraphQL

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You can’t perform that action at this time.