fetch-graphql-schema

fetch GraphQL schema via introspection query

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
fetch-graphql-schema
0.2.17 years ago7 years agoMinified + gzip package size for fetch-graphql-schema in KB

Readme

fetch-graphql-schema
!NPM versionnpm-imagenpm-url !Build Statustravis-imagetravis-url !Test coveragecoveralls-imagecoveralls-url !Dependency Statusdavidimgdavidsite
fetch GraphQL schema via introspection query

Install

$ npm install fetch-graphql-schema

Usage

const fetchSchema = require('fetch-graphql-schema');

fetchSchema('http://localhost:8080/graphql')
  .then(schemaJSON => {
    /**
     * {
     *   "data": {
     *     "__schema": {
     *       "queryType": {
     *         "name": "Query"
     *          ....
     */
  });

fetchSchema('http://localhost:8080/graphql', { readable: true })
  .then(clientSchema => {
    /**
     * type User implements Node {
     *   id: ID!
     *   name: String!
     * }
     */
  });
//=>

API

fetchGraphqlSchema(url, options)

url

Required Type: string
URL of GraphQL server.

options

readable
Type: boolean Default: false
resolve .graphql instead of .json.

CLI

Usage

$ fetch-graphql-schema <schemaUrl>

Options

-o, --output    Specify an output filename.
-r, --readable  Resolve .graphql instead of .json.

Examples

$ fetch-graphql-schema http://api.server/graphql -o schema.json
$ fetch-graphql-schema http://api.server/graphql -o schema.graphql -r

License

MIT © C.T. Lin