Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mateusmaso/graphql-jay
GraphQL schema generator for composing Web APIs
https://github.com/mateusmaso/graphql-jay
graphql javascript json json-hyper-schema json-rpc json-schema rest
Last synced: 25 days ago
JSON representation
GraphQL schema generator for composing Web APIs
- Host: GitHub
- URL: https://github.com/mateusmaso/graphql-jay
- Owner: mateusmaso
- Created: 2016-08-11T05:28:23.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-05T23:04:21.000Z (almost 8 years ago)
- Last Synced: 2024-10-05T08:47:21.064Z (about 1 month ago)
- Topics: graphql, javascript, json, json-hyper-schema, json-rpc, json-schema, rest
- Language: JavaScript
- Homepage:
- Size: 220 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graphql-jay [![Build Status](https://travis-ci.org/mateusmaso/graphql-jay.svg?branch=master)](https://travis-ci.org/mateusmaso/graphql-jay)
This is a GraphQL schema generator for composing Web APIs. It embraces the idea of querying data from multiple services (GraphQL API, REST API, JSON-RPC API, etc) within a single and unified GraphQL schema using the least expensive route available. By automating the data fetching process, it allows teams to constantly reason, experiment and perform changes on the API specification without versioning in order to solve data-flow problems.
## Install
```
$ npm install --save graphql-jay
```## Usage
```javascript
import {graphql} from "graphql"
import {composeSchema} from "graphql-jay"
import {v1, rpc, graph} from "./services"composeSchema(v1, rpc, graph).then((schema) => {
graphql(schema, `{
user(id: 1) {
id
name
posts {
id
creator {
id
image {
small
}
}
}
}
}`).then((response) => {
var {user} = response.data
})
})
```## Defining Services
### GraphQL API
```javascript
import fetch from "isomorphic-fetch"
import {introspectionQuery} from "graphql"var url = "http://myservice.com/graphql"
export default function service() {
return fetch(url, {
body: JSON.stringify({
query: introspectionQuery,
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: 'POST'
}).then((response) => {
return response.json()
}).then((response) => {
var wrapper = {
User: {
"imageUrl": "image.small"
}
}return {
url,
metadata: response.data,
wrapper
}
})
}
```### REST API
- [JSON Hyper-Schema](https://www.github.com/mateusmaso/graphql-jay-hyperschema)
- RAML
- API Blueprint
- Swagger## Examples
#### [SWAPI](https://www.github.com/mateusmaso/graphql-jay/tree/master/examples/swapi)
## License
MIT © [Mateus Maso](http://www.mateusmaso.com)