Add support for printing JSON schema, generate on build

This commit is contained in:
Brian Beck 2016-08-30 18:39:28 -07:00
parent 9adf218ebe
commit d67e6433b4
3 changed files with 6982 additions and 4 deletions

View file

@ -8,7 +8,7 @@
"npm": "^3.10.5"
},
"scripts": {
"build": "npm run build:lib",
"build": "npm run build:lib && npm run update-schema",
"build:lib": "babel --out-dir lib src",
"clean": "npm run clean:lib",
"clean:lib": "rm -rf lib",
@ -17,9 +17,11 @@
"lint": "standard --verbose | snazzy",
"prepublish": "npm run clean && npm run check && npm run build",
"print-schema": "babel-node scripts/print-schema.js",
"print-schema:json": "babel-node scripts/print-schema.js --json",
"start": "node lib/index.js",
"start:dev": "nodemon --exec babel-node src/index.js",
"test": "mocha --compilers js:babel-register"
"test": "mocha --compilers js:babel-register",
"update-schema": "npm run -s print-schema:json > schema.json"
},
"keywords": [],
"homepage": "https://github.com/exogen/graphbrainz",

6966
schema.json Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,14 @@
import { printSchema } from 'graphql'
import { graphql, introspectionQuery, printSchema } from 'graphql'
import schema from '../src/schema'
console.log(printSchema(schema))
if (require.main === module) {
if (process.argv[2] === '--json') {
graphql(schema, introspectionQuery).then(result => {
console.log(JSON.stringify(result, null, 2))
}).catch(err => {
console.error(err)
})
} else {
console.log(printSchema(schema))
}
}