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

Apollo Server 2 Hapi response toolkit is undefined #1382

Closed
tonychuuy opened this issue Jul 20, 2018 · 3 comments
Closed

Apollo Server 2 Hapi response toolkit is undefined #1382

tonychuuy opened this issue Jul 20, 2018 · 3 comments
Labels
🌹 has-reproduction ❤ Has a reproduction in Glitch, CodeSandbox or Git repository.

Comments

@tonychuuy
Copy link

I'm trying to include a cookie in the response but the response toolkit is undefined when accessed in the context method.

new ApolloServer({
  typeDefs,
  resolvers,
  context: async ({ request, h }) => {
    return { ... };
  },
})

https://github.com/apollographql/apollo-server/tree/master/packages/apollo-server-hapi

h is undefined

My current server configuration

const server = new ApolloServer({
    typeDefs,
    resolvers,
    schemaDirectives,
    context: async ({ request, h }) => {
      console.log('h', h);
      return {
        request,
          h,
      };
    },
    formatError: (error) => formatError(error, app),
    tracing: true,
  });

Am I doing something wrong here?

@ghost ghost added the 🌹 has-reproduction ❤ Has a reproduction in Glitch, CodeSandbox or Git repository. label Jul 20, 2018
@tonychuuy tonychuuy changed the title Hapi response toolkit is undefined Apollo Server 2 Hapi response toolkit is undefined Jul 20, 2018
@ghost ghost added the 🌹 has-reproduction ❤ Has a reproduction in Glitch, CodeSandbox or Git repository. label Jul 20, 2018
@maxnachlinger
Copy link
Contributor

Looks like adding h to the [request] array here: https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-hapi/src/hapiApollo.ts#L44 fixes the issue.

@tonychuuy
Copy link
Author

nice, thanks for the fix

evans pushed a commit that referenced this issue Jul 27, 2018
* Fix for #1382

* fix typo in changelog

* Added a few tests proving the response toolkit is passed into the context function
@wesselvdv
Copy link

Anyone wanna cut a new version? I really need this fix. :-)

@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
🌹 has-reproduction ❤ Has a reproduction in Glitch, CodeSandbox or Git repository.
Projects
None yet
Development

No branches or pull requests

3 participants