https://github.com/yoctol/fetch-graphql-schema
fetch GraphQL schema via introspection query
https://github.com/yoctol/fetch-graphql-schema
Last synced: about 1 year ago
JSON representation
fetch GraphQL schema via introspection query
- Host: GitHub
- URL: https://github.com/yoctol/fetch-graphql-schema
- Owner: Yoctol
- License: mit
- Created: 2016-11-11T14:03:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-09-21T03:28:14.000Z (over 5 years ago)
- Last Synced: 2025-04-20T02:12:13.110Z (about 1 year ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 28
- Watchers: 8
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# fetch-graphql-schema
[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Dependency Status][david_img]][david_site]
> fetch GraphQL schema via introspection query
## Install
```
$ npm install fetch-graphql-schema
```
## Usage
```js
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!
* }
*/
});
//=>
```
## API
### fetchGraphqlSchema(url, [options])
#### url
*Required*
Type: `string`
URL of GraphQL server.
#### options
##### readable
Type: `boolean`
Default: `false`
resolve `.graphql` instead of `.json`.
## CLI
#### Usage
```
$ fetch-graphql-schema
```
#### Options
```
-o, --output Specify an output filename.
-r, --readable Resolve .graphql instead of .json.
```
#### Examples
```
$ fetch-graphql-schema http://api.server/graphql -o schema.json
$ fetch-graphql-schema http://api.server/graphql -o schema.graphql -r
```
## License
MIT © [C.T. Lin](https://github.com/Yoctol/fetch-graphql-schema)
[npm-image]: https://badge.fury.io/js/fetch-graphql-schema.svg
[npm-url]: https://npmjs.org/package/fetch-graphql-schema
[travis-image]: https://travis-ci.org/Yoctol/fetch-graphql-schema.svg
[travis-url]: https://travis-ci.org/Yoctol/fetch-graphql-schema
[coveralls-image]: https://coveralls.io/repos/Yoctol/fetch-graphql-schema/badge.svg?branch=master&service=github
[coveralls-url]: https://coveralls.io/r/Yoctol/fetch-graphql-schema?branch=master
[david_img]: https://david-dm.org/Yoctol/fetch-graphql-schema.svg
[david_site]: https://david-dm.org/Yoctol/fetch-graphql-schema