mirror of
https://github.com/vale981/apollo-server
synced 2025-03-06 10:11:40 -05:00
doc(get-support): update README.md for GET method examples
This commit is contained in:
parent
a2d7c85ff2
commit
7abcee8398
1 changed files with 34 additions and 2 deletions
36
README.md
36
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.
|
||||
|
|
Loading…
Add table
Reference in a new issue