doc(get-support): update README.md for GET method examples

This commit is contained in:
Hagai Cohen 2016-10-20 21:19:52 +03:00
parent a2d7c85ff2
commit 7abcee8398

View file

@ -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.