I have a GraphQLModule which I'm configuring with the schema property. That all works fine and I can use my subgraph as expected. The one thing I can't seem to figure out is how to get my guards to work with that. Is there any way to hook an APP_GUARD into the resolvers that correspond to the schema property? My guards work for any resolvers that are registered with @Resolver, but all of my guards/pipes/interceptors/etc do not run on anything that comes from schema.
#How to enable NestJS request lifecycle (guards/interceptors/etc) on GraphQLModule `options.schema`
9 messages · Page 1 of 1 (latest)
So, with some further exploration I think the issue here is that guards/interceptors/etc are wired up to the resolvers via the resolver-explorer.service. Given that the output from the schema is not ran through that, those resolvers from schema don't get piped through the normal nest request lifecycle. Is there any suggested way to wire up the resolvers from schema to get ran within the nest request lifecycle?
@steady sandal , sorry to toss an @ on here. Any chance you've got some ideas for this, or any individual in particular that may be able to lend a hand here? I think this is something that definitely falls outside of "normal" for the framework, so I'm thinking that I'll need to come up with some bespoke solution for this. That said, I feel like this is a capability that could be beneficial to teams looking to adopt Nest
How to enable NestJS request lifecycle (guards/interceptors/etc) on GraphQLModule options.schema
I'm 99% certain enabling field level enchancers won't solve it, but maybe worth double-checking? https://docs.nestjs.com/graphql/other-features#execute-enhancers-at-the-field-resolver-level
Or maybe global field middleware could be used to trigger something simulating the enhancers behavior? https://docs.nestjs.com/graphql/field-middleware#global-field-middleware
Yeah, this was my first guess. It didn't seem to do anything.
Oh, interesting. I missed this in the docs. I'll give it a shot
@light elk , I gave this a shot but it unfortunately didn't seem to help. This seems to leave apollo plugins, or vanilla express middleware as options. Any other ideas than those?