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

Hono / GraphQL / Pothos integration issues #198

Open
armstrong-pv opened this issue Oct 7, 2023 · 1 comment
Open

Hono / GraphQL / Pothos integration issues #198

armstrong-pv opened this issue Oct 7, 2023 · 1 comment

Comments

@armstrong-pv
Copy link

armstrong-pv commented Oct 7, 2023

Full repro, including tests located here: https://github.com/armstrong-pv/hono-pothos-issue-repro

First of all, I'm really enjoying using Hono - great job on speed and simplicity 👏. I initially started with plain REST, but then moved on to using GraphQL using the middleware you provide. Pothos is a type safe GraphQL schema builder which I'd really like to use together with Hono, but I'm having some issues trying to get them to work together.

  1. Context Propagation
    I can get the context from the pipeline to go to a root resolver, but not to go to individual resolvers, e.g. for mutations.
  2. When I try to use authScopes for resolvers, the GraphQL processing returns this error: "Invalid value used as weak map key". I raised an issue in the Pothos repo here: Hono / Pothos scopes integration error hayes/pothos#1064, and the author thinks it's related to propagating the context object, so if 1 is solved, then this should be solved also.
  3. It would be nice to opt out of the GraphQL error handling, e.g. by returning a plain old 401 http code, but everything gets wrapped in a GraphQL error. Not sure if there's anything that can be done about this.

I'm using Cloudflare Workers and it's not trivial to get everything up and running, so I have created a full repro of these issues, along with tests that demonstrate them at this repo: https://github.com/armstrong-pv/hono-pothos-issue-repro

There is a readme which covers setting everything up and running the tests: https://github.com/armstrong-pv/hono-pothos-issue-repro/blob/main/README.md.
It's pretty straightforward:

npm install
npm run tests

If you want to run in dev mode:

npm run dev

Many thanks!

@metrue
Copy link
Contributor

metrue commented Jan 25, 2024

Thanks @armstrong-pv , I will take a look at it.

Just created a pull request to fix the context propagation issue. #361

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

2 participants