Skip to content

Latest commit

 

History

History
52 lines (32 loc) · 1.88 KB

README.md

File metadata and controls

52 lines (32 loc) · 1.88 KB

Apollo Server - Express, Connect, Hapi, Koa

A very basic example application using Apollo Server for the Express, Connect, Hapi and Koa frameworks as based on the Apollo Server docs.

The below covers the following:

  • GraphQL Tools makeExecutableScehma
  • Basic Resolvers
  • Basic Mocking
  • GraphiQL

The server files can be found for the respective frameworks in the following:

You can run each seperately using the following scripts:

  • npm run server:express
  • npm run server:connect
  • npm run server:hapi
  • npm run server:koa

Gotcha's

The following are gotcha's I ran into that aren't clear when working with Apollo Server:

  • Koa - must be version 2 or higher, use npm i --save koa@2
  • Koa Router - must be version 7 or higher, use npm i --save koa-router@7
  • Koa Body Parser - must be version 3 or higher, use npm i --save koa-bodyparser@3
  • Hapi - currently GraphiQL is experiencing issues. It seems to be due to the deep copying of plugin options by Hapi. See this thread for more - apollographql/apollo-server#158 (comment). A temporary workaround is provided in that thread and detailed below.

Hapi GraphiQL workaround

Passing the apolloOptions in as a function instead of plain object will workaroud the GraphiQL issues. See server.hapi.js for an example.

apolloOptions: () => ({
  schema: executableSchema,
  context: {},
}),

Follow apollo-server issue #158 for more information on this issue and its resolution.