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

Feature request: add option for context factory function #154

Closed
andrew0 opened this issue Jan 23, 2022 · 1 comment
Closed

Feature request: add option for context factory function #154

andrew0 opened this issue Jan 23, 2022 · 1 comment

Comments

@andrew0
Copy link

andrew0 commented Jan 23, 2022

I'd like to be able to set the context of my GraphQL resolvers to ctx.state rather than just ctx. With many other GraphQL server implementations, I could do something like graphqlHTTP({ schema, context: (ctx) => ctx.state }), but this library only allows you to pass a static value as the context.

Since the default context is the Koa ctx, I could just use ctx.state in my resolvers, but I'd prefer to decouple the raw request details from my resolvers since it makes it easier to mock the context in tests.

@andrew0
Copy link
Author

andrew0 commented Jan 23, 2022

realizing now that the whole options can be a function...

@andrew0 andrew0 closed this as completed Jan 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant