https://github.com/nimitzdev/think-graphql-middleware
A ThinkJS middleware that handles GraphQL queries, built atop apollo-server-core
https://github.com/nimitzdev/think-graphql-middleware
Last synced: about 1 year ago
JSON representation
A ThinkJS middleware that handles GraphQL queries, built atop apollo-server-core
- Host: GitHub
- URL: https://github.com/nimitzdev/think-graphql-middleware
- Owner: NimitzDEV
- Created: 2018-07-22T05:17:02.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-22T05:58:08.000Z (almost 8 years ago)
- Last Synced: 2024-03-24T22:01:50.755Z (about 2 years ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# think-graphql-middleware
> A ThinkJS middleware that handles GraphQL queries, built atop apollo-server-core.
#### Install
```bash
npm install think-graphql-middleware --save
```
#### Usage
Require the middleware at `src/config/middleware.js`
```javascript
const graphql = require('think-graphql-middleware');
```
Set-up `match` for your desired GraphQL endpoint, and use `graphql` for `handle` parameter.
```javascript
{
match: '/graphql',
handle: graphql,
options: {}
}
```
Then pass your `GraphQLSchema`instance to `schema` option.
```javascript
options: {
schema: schemaInstant
}
```
#### More details
This middleware is based on `apollo-server-core`, more usages can be found at the [Apollo Official Site.](https://www.apollographql.com/docs/apollo-server/api/apollo-server.html)