fetch GraphQL schema via introspection query
$ npm install fetch-graphql-schema
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!
* }
*/
});
//=>
Required
Type: string
URL of GraphQL server.
Type: boolean
Default: false
resolve .graphql
instead of .json
.
$ fetch-graphql-schema <schemaUrl>
-o, --output Specify an output filename.
-r, --readable Resolve .graphql instead of .json.
$ fetch-graphql-schema http://api.server/graphql -o schema.json
$ fetch-graphql-schema http://api.server/graphql -o schema.graphql -r
MIT © C.T. Lin