How to use @envelop/*
plugins and set the Context?
#341
Unanswered
mrcleanandfresh
asked this question in
Docs Discussion
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The docs mention that KitQL uses GraphQL Yoga and Envelop under the hood, which I was really excited about. Before I found this project, I was trying to set up something very similar to this on my own. So I was very excited to try it, but felt the documentation very "alpha" in nature. I almost felt like I was missing some foundational knowledge that was expected. But I was able to piece things together and get it working.
Now I wanted to use an
@envelop/auth0
plugin as well as some other plugins. I looked all over the docs and I felt it was missing was"how to use
@envelop/*
plugins" even though the tool uses it under the hood.I am trying to use some of them, but I keep getting type errors when trying to put them in the plugin array. This is my code:
I also tried to use it like this, with some success, but it's the auth0 plugin doesn't seem to be present at all within the context. I am also getting type errors when trying to put anything in the plugin array. The
Plugin[]
type comes from GraphQL Yoga within KitQL, so I assume I can use it like the above. Originally, I tried to do it like this:If KitQL does
envelop
ing under the hood, I would expect the context to be:Or some kind of indication of whether I should be spreading existing context in to get the same result, like so:
I'm just confused and could really use some clarification. Some questions I have:
getEnveloped
for requests under the hood? Am I doing double work using the context factory?getEnveloped
under the hood, do I simply provide a list of enveloped plugins and it will "envelop" them internally? Or is it a private part of the KitQL API?ctx.ts
file that gets generated with an empty object export? Seems like a good place to add my PrismaClient to the object, since it has a comment// no DbProvider found
above the empty object.Any help would be greatly appreciated. Trying to figure out how to add authentication but am pretty lost based on the lack of docs.
P.S. Another annoying thing is I am on Windows, and the generator keeps generating code like this:
Then Vite gives me errors:
Changing the import to:
fixes this issue until the next time KitQL recompiles, and I have to change it again.
Beta Was this translation helpful? Give feedback.
All reactions