From 9cfb1bbfd0a0261ac29b418afd5b8e2100644cdc Mon Sep 17 00:00:00 2001 From: Paul Le Cam Date: Thu, 3 Nov 2016 17:35:42 +0000 Subject: [PATCH] Add documentation --- README.md | 26 +++++++++++++++++++++++++- package.json | 3 ++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7980af0..fdc6101 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,13 @@ Fetch a GraphQL schema from a server and write it to file -## Usage +## Installation + +```sh +npm install graphql-fetch-schema +``` + +## CLI Usage ```sh graphql-fetch-schema [options] @@ -18,6 +24,24 @@ graphql-fetch-schema [options] -o, --output write to specified directory ``` +### API usage + +```js +import fetchSchema from 'graphql-fetch-schema' + +fetchSchema('https://api.myserver.com/graphql', { + json: true, + graphql: false, + outputPath: '../schema', +}) +.then(() => { + console.log('Schema successfully written') +}) +.catch((err) => { + console.error(err) +}) +``` + ## License MIT diff --git a/package.json b/package.json index ed6cf9d..6731114 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "clean": "rm -rf ./lib", "compile": "babel src --out-dir lib", "build": "npm run clean && npm run compile", - "start": "npm run compile" + "start": "npm run compile", + "prepublish": "npm ls && npm start" }, "author": "Paul Le Cam ", "license": "MIT",