From 7abcee839832916282756faed9ea4088167e6409 Mon Sep 17 00:00:00 2001 From: Hagai Cohen Date: Thu, 20 Oct 2016 21:19:52 +0300 Subject: [PATCH] doc(get-support): update README.md for GET method examples --- README.md | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b7561c61..b8dcd01a 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ where variant is one of the following: - koa - hapi -### Express +### Express ( POST ) ```js import express from 'express'; @@ -49,7 +49,23 @@ app.use('/graphql', bodyParser.json(), graphqlExpress({ schema: myGraphQLSchema app.listen(PORT); ``` -### Connect +### Express ( GET ) + +```js +import express from 'express'; +import { graphqlExpress } from 'graphql-server-express'; + +const myGraphQLSchema = // ... define or import your schema here! +const PORT = 3000; + +var app = express(); + +app.use('/graphql', graphqlExpress({ schema: myGraphQLSchema })); + +app.listen(PORT); +``` + +### Connect ( POST ) ```js import connect from 'connect'; import bodyParser from 'body-parser'; @@ -66,6 +82,22 @@ app.use('/graphql', graphqlConnect({ schema: myGraphQLSchema })); http.createServer(app).listen(PORT); ``` +### Connect ( GET ) +```js +import connect from 'connect'; +import { graphqlConnect } from 'graphql-server-express'; +import http from 'http'; + +const PORT = 3000; + +var app = connect(); + +app.use('/graphql', require('connect-query')()); +app.use('/graphql', graphqlConnect({ schema: myGraphQLSchema })); + +http.createServer(app).listen(PORT); +``` + ### Hapi Now with the Hapi plugins `graphqlHapi` and `graphiqlHapi` you can pass a route object that includes options to be applied to the route. The example below enables CORS on the `/graphql` route.