redwood
redwood copied to clipboard
[Bug]: Graphql handler is not executed if it's a wrapper
What's not working?
When creating a wrapper called handler around createGraphQLHandler
function it never get executed.
Example graphql.ts
const graphqlHandler = createGraphQLHandler({
loggerConfig: { logger, options: {} },
directives,
sdls,
services,
onException: () => {
// Disconnect from your database with an unhandled exception.
db.$disconnect()
},
})
export async function handler(event, context) {
// this never gets fired
console.log(`in handler wrapper`)
const requestIdHeader = 'x-request-id'
const requestId = event.headers[requestIdHeader]
const store: Store = new Map([['requestId', requestId]])
const response = await executionContext.run(store, () => {
return graphqlHandler(event, context)
})
return {
...response,
headers: { ...(response.headers ?? {}), [requestIdHeader]: requestId },
}
}
When you run this app, the console.log(
in handler wrapper)
never gets fired.
How do we reproduce the bug?
- clone https://github.com/jan-stehlik/rw-graphql-issue/tree/main
- yarn install
- yarn rw dev
- open http://localhost:8910/ and have a look at server logs -
console.log(
in handler wrapper)
doesn't get triggered
What's your environment? (If it applies)
Redwood 8.0.0
Node 20.16
Yarn 4.4
Are you interested in working on this?
- [ ] I'm interested in working on this