Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ammezie/adonis-apollo-server
Production-ready Node.js GraphQL server for AdonisJS
https://github.com/ammezie/adonis-apollo-server
adonisjs apollographql graphql graphql-server
Last synced: 15 days ago
JSON representation
Production-ready Node.js GraphQL server for AdonisJS
- Host: GitHub
- URL: https://github.com/ammezie/adonis-apollo-server
- Owner: ammezie
- Created: 2017-09-14T06:18:16.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-09T22:39:38.000Z (almost 5 years ago)
- Last Synced: 2024-10-15T00:58:02.981Z (29 days ago)
- Topics: adonisjs, apollographql, graphql, graphql-server
- Language: JavaScript
- Size: 24.4 KB
- Stars: 66
- Watchers: 3
- Forks: 11
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-adonisjs-packages - Adonis Apollo Server - Production-ready Node.js GraphQL server for AdonisJs (Databases, ORMs, Migrations & Seeding)
README
# adonis-apollo-server
This package integrates Apollo GraphQL Server with the AdonisJS framework. It allows you to use Apollo server in your AdoinsJS app.
> **NOTE:** This package requires [@adonisjs/bodyparser](https://github.com/adonisjs/adonis-bodyparser)
## Installation
```bash
adonis install adonis-apollo-server
```### Registering provider
Make sure to register the provider inside `start/app.js` file.
```js
const providers = [
'adonis-apollo-server/providers/ApolloServerProvider'
]
```That's all!
## Usage
Now you can use the provider by pulling it from IoC container
```js
// start/routes.js'use strict'
const Route = use('Route')
const ApolloServer = use('ApolloServer')
const { makeExecutableSchema } = require('graphql-tools')const typeDefs = `
type Query {
testString: String
}
`const resolvers = {
Query: {
testString () {
return 'Seems to be working!'
}
}
}const schema = makeExecutableSchema({ typeDefs, resolvers })
Route.route('/graphql', ({ request, response }) => {
return ApolloServer.graphql({ schema }, request, response)
}, ['GET', 'POST'])Route.get('/graphiql', ({ request, response }) => {
return ApolloServer.graphiql({ endpointURL: '/graphql' }, request, response)
})
```