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.
$ npm install --save graphql-jay
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
email
image {
small
}
}
}
}
}`).then((response) => {
var {user} = response.data
})
})
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
}
})
}
- JSON Hyper-Schema
- RAML
- API Blueprint
- Swagger
MIT © Mateus Maso