Not able to access response object from context in apollo-server-fastify
See original GitHub issuePreviously I was using apollo-server-express
and I wanted to migrate to fastify so I change it to apollo-server-fastify
. But it started giving lots of issues.
One of such issue is - Not able to access res
object from context function.
Below code was working perfectly but res object itself was not available with apollo-server-fastify
context: async ({ req, res, connection }) => {
// res <--------- undefined
if (connection) {
return {
models,
}
}
if (req) {
const me = await getMe(req, res)
return {
models,
me,
secret: process.env.SECRET,
}
}
},
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (3 by maintainers)
Top Results From Across the Web
API Reference: ApolloServer - Apollo GraphQL Docs
This article documents the ApolloServer class from the @apollo/server package. You can use the ApolloServer class to create an instance of Apollo Server...
Read more >Authentication and authorization - Apollo GraphQL Docs
Before we can correctly control access to data, we have to authenticate a user. There are many patterns for providing authentication credentials, including...
Read more >Migrating to Apollo Server 4 - Apollo GraphQL Docs
The willSendResponse plugin hook receives an operation's requestContext , which has a response field containing a GraphQLResponse object. Note that the ...
Read more >Apollo Server 4: a lightweight and easier-to-use Apollo Server
Apollo Server 4 is a lightweight, open-source, spec-compliant GraphQL server that's compatible with any GraphQL client.
Read more >Context and contextValue - Apollo GraphQL Docs
By default, if your context function throws an error, Apollo Server returns that error in a JSON response with a 500 HTTP status...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, the same issue but you can pass
reply
instance manually.File
plugins/fastify-apollo-server/index.js
File:
init-server.js
#3895 is awaiting review. In the meantime I’ve published a standalone version of apollo-server-fastify with the fix applied, here: https://github.com/autotelic/apollo-server-fastify.