Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0rc hapi integration - runtime error when gui: true #1195

Closed
SkaterDad opened this issue Jun 19, 2018 · 4 comments
Closed

2.0rc hapi integration - runtime error when gui: true #1195

SkaterDad opened this issue Jun 19, 2018 · 4 comments

Comments

@SkaterDad
Copy link

When trying to add Apollo Server 2.0rc to my existing hapi project last night, I ran into a runtime error when attempting to use the GUI. I was able to POST requests just fine, but could not open GraphQL Playground.

I wanted to debug it a bit last night, but the transpiled code is very hard to follow. It would be so much easier if you didn't have to support Node 6 anymore, or could ship a build that's usable natively for Node 8+.

Minimal code to reproduce (Also on Glitch)

var Hapi = require('hapi')

var { ApolloServer, gql } = require('apollo-server-hapi')

var server = new Hapi.Server({ port: process.env.PORT })


var typeDefs = gql`
  type Query {
    hello: String
  }
`

var resolvers = {
  Query: {
    hello: () => "Test"
  }
}

var apollo = new ApolloServer({ typeDefs, resolvers })
apollo.applyMiddleware({
  app: server,
  gui: true,
  path: '/' 
})

server.start().then(() => console.log('running'))
Debug: internal, implementation, error 

    TypeError: Cannot read property 'subscriptionsPath' of null

    at /rbd/pnpm-volume/485b790f-ae73-40af-a553-dae4f20dd9bd/node_modules/.registry.npmjs.org/apollo-server-hapi/2.0.0-rc.0/node_modules/apollo-server-hapi/dist/ApolloServer.js:67:118

    at Generator.next (<anonymous>)

    at fulfilled (/rbd/pnpm-volume/485b790f-ae73-40af-a553-dae4f20dd9bd/node_modules/.registry.npmjs.org/apollo-server-hapi/2.0.0-rc.0/node_modules/apollo-server-hapi/dist/ApolloServer.js:4:58)

    at <anonymous>

    at process._tickCallback (internal/process/next_tick.js:188:7)
@evans
Copy link
Contributor

evans commented Jun 20, 2018

Ah thank you for reporting the issue! I'm taking a look and will add some of the tests that we are using for the express integration

evans added a commit that referenced this issue Jun 20, 2018
evans added a commit that referenced this issue Jun 20, 2018
evans added a commit that referenced this issue Jun 20, 2018
evans added a commit that referenced this issue Jun 20, 2018
@evans
Copy link
Contributor

evans commented Jun 21, 2018

We've released RC.1, which contains #1211, so the issue should be resolved. Thank you for flagging it @SkaterDad!

@evans evans closed this as completed Jun 21, 2018
@evans
Copy link
Contributor

evans commented Jun 21, 2018

Also thank you so much for the reproduction! See https://glitch.com/edit/#!/hapi-as2?path=server.js:13:17 for a fork that upgrades to the latest RC

@SkaterDad
Copy link
Author

@evans Thanks for the quick fix! Apollo 2.0 is a really exciting project 👍

Would you be willing to add the ability to pass more hapi route options to the plugin/routes, not just cors? hapi servers can be set up with default options that get applied to each route, and get overridden on a case-by-case basis.

There are quite a few route options: https://hapijs.com/api#route-options

For my own cases, I can see auth, cors, and cache being useful/necessary, but other people may need more.

GraphQL handles auth in such a different way, I need to provide a different auth config object to the endpoint. My server's default auth strategy requires admin rights, but I would want the GraphQL endpoint to have optional auth that I can attach to the context object if present to do access control at the resolver level.

I can create a new issue, or post this in an existing issue if you prefer for tracking purposes.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants