-
Notifications
You must be signed in to change notification settings - Fork 390
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
Add a @DirectiveResolver decorator #21
Comments
The more I read into graphql (I'm still a newbie), the more I think NestJs should embrace SchemaDirectives instead / also :-) |
Any updates on this issue? |
New Nevertheless, we didn't ship To register directive resolver, simply pass |
Thanks @kamilmysliwiec - can you provide a simplistic working example? PS: I made it work as PoC back with NestJs 4.6 & @nestjs/graphql 2.0.0 with this hack:
|
@kamilmysliwiec I am also interested in an example how to add directive support "the intended way". |
I made some PoC on how to use dependency injection in Directive classes, it requires one ugly hack but looks slick.
directives.module.ts
directives.factory.ts
And last one rest-directive.ts
|
Then you use can use it like this from schema:
|
@sebastian-schlecht check out couple of comments above, I posted some workaround to this |
Is there any workaround how I can use directives in a code-first approach? |
@lookapanda I have open a ticket for that problem. Hope anyone can add the new version from type-graphql: |
@Ponjimon |
Currently, NestJS doesn't support GraphQL directives at all, since the
directiveResolvers
inmakeExecutableSchema
is missing https://github.com/nestjs/graphql/blob/master/lib/graphql.factory.ts#L28I wanted to use directives in my model (for authentication etc) and I bumped into #17 but I realized it's not just the mapping to Guards, but that NestJS is totally missing directives.
PS: An example of how to use Directives https://codeburst.io/use-custom-directives-to-protect-your-graphql-apis-a78cbbe17355 and how
graphql-tools
implements it here https://github.com/apollographql/graphql-tools/blob/master/docs/source/directive-resolvers.md#directive-exampleThe text was updated successfully, but these errors were encountered: