Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 933 Bytes

README.md

File metadata and controls

53 lines (41 loc) · 933 Bytes

graphql-fetch-schema

Fetch a GraphQL schema from a server and write it to file

Installation

npm install graphql-fetch-schema

CLI Usage

graphql-fetch-schema <url> [options]

Options

-h, --help                output usage information
-V, --version             output the version number
-c, --cookie              pass additional Cookie header
-g, --graphql             write schema.graphql file
-j, --json                write schema.json file
-o, --output <directory>  write to specified directory

API usage

import fetchSchema from 'graphql-fetch-schema'

fetchSchema('https://api.myserver.com/graphql', {
  json: true,
  graphql: false,
  outputPath: '../schema',
  cookie: 'cookiename=foo;',
  headers: {
    Authorization: 'Bearer token'
  }
}).then(
  () => {
    console.log('Schema successfully written')
  },
  err => {
    console.error(err)
  },
)

License

MIT