Is it possible to add middleware à la express? #273
-
In my current
The most important thing to me is being able to continue using |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 3 replies
-
It’s not exposed currently. I also have uncertainty that we’ll stick with express as per #231. TBD Exposing would be trivial but even as an escape hatch I’m concerned about apps depending on something we might break hard. Maybe we could make the server component swappable... different plugins. |
Beta Was this translation helpful? Give feedback.
-
@jasonkuhrt ah yes, I'd seen that issue- If a large perf increase can be had, I'm all for it, even if it means I can't get parity with what I currently have. Swappable server sounds interesting, I'd be interested to hear that fleshed out. If I had to choose between perf increase and being able to use express session, I'd probably lean toward perf. However if I can't include the express session middleware in my GQL/prisma/santa server, that likely means putting it in another server and adding latency. So there's a chance the perf gain from switching to This is just my own situation- obviously you should design for what the majority of users want. If this doesn't end up being something a lot of people do, then I'd understand just not exposing the functionality. I'd be interested to see how other people are handling sessions when using GQL servers, just as an aside! |
Beta Was this translation helpful? Give feedback.
-
Hey @nhuesmann check out #523 |
Beta Was this translation helpful? Give feedback.
-
@jasonkuhrt Hey, just checked out #523, need some time to digest. Would I be using |
Beta Was this translation helpful? Give feedback.
-
Correct. But, of course, only to the extent the the Nexus API does what you need.
Correct. FYI related #524. |
Beta Was this translation helpful? Give feedback.
-
Oh #524 is interesting, with having the import { context } from 'nexus-future'
context.foo = 'bar' |
Beta Was this translation helpful? Give feedback.
-
@nhuesmann tbd, up for discussion |
Beta Was this translation helpful? Give feedback.
-
@nhuesmann fyi I migrated this from gh issues to gh discussions. I think it makes sense. Hope that's ok with you. |
Beta Was this translation helpful? Give feedback.
-
@jasonkuhrt Absolutely, forgot about that feature but it makes sense as a discussion 👍🏼 |
Beta Was this translation helpful? Give feedback.
-
Hey @jasonkuhrt, how would I write a plugin similar to that of LogMutationTimePlugin in the link https://nexus.js.org/docs/api-plugins? I would like to access graphql args as well so I can write some common validation routines and few other functionality. This also helps me to use t.crud directly instead of t.field in most of the cases. I checked the below and the nexus source code, but using graphql args doesn't seem to be obvious. |
Beta Was this translation helpful? Give feedback.
-
Now that we expose express directly, I think we can close this discussion. Any objections @nhuesmann? |
Beta Was this translation helpful? Give feedback.
Now that we expose express directly, I think we can close this discussion. Any objections @nhuesmann?