mirror of
https://github.com/BradNut/graphbrainz
synced 2025-09-08 17:40:32 +00:00
Add support for printing JSON schema, generate on build
This commit is contained in:
parent
9adf218ebe
commit
d67e6433b4
3 changed files with 6982 additions and 4 deletions
|
|
@ -8,7 +8,7 @@
|
||||||
"npm": "^3.10.5"
|
"npm": "^3.10.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run build:lib",
|
"build": "npm run build:lib && npm run update-schema",
|
||||||
"build:lib": "babel --out-dir lib src",
|
"build:lib": "babel --out-dir lib src",
|
||||||
"clean": "npm run clean:lib",
|
"clean": "npm run clean:lib",
|
||||||
"clean:lib": "rm -rf lib",
|
"clean:lib": "rm -rf lib",
|
||||||
|
|
@ -17,9 +17,11 @@
|
||||||
"lint": "standard --verbose | snazzy",
|
"lint": "standard --verbose | snazzy",
|
||||||
"prepublish": "npm run clean && npm run check && npm run build",
|
"prepublish": "npm run clean && npm run check && npm run build",
|
||||||
"print-schema": "babel-node scripts/print-schema.js",
|
"print-schema": "babel-node scripts/print-schema.js",
|
||||||
|
"print-schema:json": "babel-node scripts/print-schema.js --json",
|
||||||
"start": "node lib/index.js",
|
"start": "node lib/index.js",
|
||||||
"start:dev": "nodemon --exec babel-node src/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": [],
|
"keywords": [],
|
||||||
"homepage": "https://github.com/exogen/graphbrainz",
|
"homepage": "https://github.com/exogen/graphbrainz",
|
||||||
|
|
|
||||||
6966
schema.json
Normal file
6966
schema.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,14 @@
|
||||||
import { printSchema } from 'graphql'
|
import { graphql, introspectionQuery, printSchema } from 'graphql'
|
||||||
import schema from '../src/schema'
|
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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue