0.9.0 • Published 3 years ago
@graphity-extensions/restful v0.9.0
Graphity Extensions - RESTFul
Installation
npm install @graphity-extensions/restful --save
Usage
Simple Example
import { createExpressAdapter } from "@graphity-extensions/restful"
import { ApolloServer } from "apollo-server-express"
import bodyParser from "body-parser"
const schema = { ... } // GraphQLSchema
const apollo = new ApolloServer({
schema,
})
const app = express()
apollo.applyMiddleware({app})
app.use(bodyParser())
app.use(createExpressAdapter(schema, {
endpoints: [
{
method: "GET",
path: "/",
query: (req) => ({
document: parse(`query { version }`),
})
},
{
method: "POST",
path: "/articles",
query: (req) => ({
document: parse(`mutation($title: String!, $contents: String) {
article: createArticle(title: $title, contents: $contents) {
id
title
contents
}
}`),
values: {
title: req.body.title,
contents: req.body.contents,
},
})
},
],
}))
app.listen(8080)
0.9.0
3 years ago
0.7.0
4 years ago
0.6.3
4 years ago
0.6.2
4 years ago
0.6.1
4 years ago
0.6.0
4 years ago
0.6.0-alpha.5
4 years ago
0.6.0-alpha.2
5 years ago
0.6.0-alpha.1
5 years ago