Manually create an object of type NexusContext #1371
Unanswered
brainafesoh
asked this question in
General
Replies: 1 comment
-
|
Upřímně, jdeš na to trochu špatně. NexusContext není určený k tomu, aby ses ho snažil ručně skládat někde bokem. Je to objekt, který vzniká v rámci request lifecycle a typicky obsahuje věci navázané na konkrétní request, jako auth, headers nebo response. Proto tam nedává smysl cpát prázdné req a res. Lepší přístup je oddělit business logiku od resolveru. To, co máš v allUsers, je správný směr, ale udělej z toho funkci, která bere jen prisma nebo nějaký service layer, ne celý ctx. Resolver pak jen předá ctx.db dál. Díky Betonred casino CZ tomu tu funkci můžeš volat odkudkoliv bez řešení kontextu. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, guys
I would like to manually inititialize a Nexus context object so as to be able to call a resolver function from an external function rather than from the mutation or query itself:
Not sure I'm expressing myself correctly!!
The query & resolver functions go as such;
I would like to use the resolver function without passing through the query, therefore I need to manually create a
ctxobject. Here's how I'm trying to do it, but I don't seem to figure out what has to go into thereq and resattributes;@jasonkuhrt
Beta Was this translation helpful? Give feedback.
All reactions