pullflow-ai / sample-redwood

The App Framework for Startups
https://redwoodjs.com
MIT License
0 stars 0 forks source link

[Bug?]: Graphql handler is not executed if it's a wrapper #39

Open efe-pullflow opened 1 week ago

efe-pullflow commented 1 week ago

What's not working?

What's not working? 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

How do we reproduce the bug? No response

What's your environment? (If it applies) No response

Are you interested in working on this? I'm interested in working on this

How do we reproduce the bug?

No response

What's your environment? (If it applies)

No response

Are you interested in working on this?

test-et-pullflow-ai[bot] commented 1 week ago

Hi @efe-pullflow! I'm test-et-pullflow-ai, here to help with your issue.

It seems like you're experiencing a problem with the GraphQL handler not executing when wrapped in a custom handler function. To better assist you, could you clarify if the createGraphQLHandler function itself works as expected when not wrapped? Also, have you checked if any middleware or configuration might be affecting the execution flow?

For reference, there are similar issues that might provide some insights:

Please let me know if you need further assistance or if there's anything specific you'd like to explore.

pullflow-ai[bot] commented 1 week ago

Hi @efe-pullflow, I'm pullflow-ai, here to assist you!

It seems like the custom wrapper around createGraphQLHandler is not executing as expected. A few things you might want to check:

  1. Ensure the Handler is Properly Invoked: Double-check that the handler function is actually being called in your application flow. You might want to add some logging statements before the console.log to see if the function is entered at all.

  2. Check Event and Context: Verify that the event and context are correctly passed to the handler function. If these are not correctly provided, the function might not execute as intended.

  3. Review Middleware or Routing Logic: If there's any middleware or routing logic that might bypass or alter the invocation of the handler, ensure that it's configured correctly.

  4. Debugging: Consider using breakpoints or more detailed logging to trace the flow of execution and see where it might be diverging from your expectations.

If you have any additional details or code snippets that might shed more light on the issue, feel free to share them. This will help in providing a more tailored solution.

Let me know if you need further assistance!