This would be a great nice to have,
and it could narrow to something as simple as hooks during the instantiation of the express server.
I think there is a good example about authentication via directives: https://github.com/chenkie/graphql-auth
interesting...
I was about to propose yoga-middlewares, but obviously implementing authentication via the resolvers is another option. I guess, it depends if yoga is a lean or fullstack framework.
Went over your code... then found this issue https://github.com/chenkie/graphql-auth/issues/2
That's a real problem... and a waste of resources. not to mention the side-effects for mutations.
This leads me to believe that yoga could benefit from a better middleware implementation, in fact something like this https://github.com/scaphold-io/graphql-extended/blob/master/src/middleware/Middleware.ts
which allows the implementation of any type of middleware, not just AAA
@orefalo: We can create two directives like @authBefore(roleIds: [string]) and @authAfter(roleIds: [string]) to do same thing as middlewares.
roleIds is a optional variable, if set user must log in and has least one of the roles
@giautm I would gladly look at some samples ;-) No idea how to get it done.
Actually found this project, which seems to be in perfect alignment
https://github.com/thebigredgeek/apollo-resolvers
Video's really good
https://www.youtube.com/watch?v=xaorvBjCE7A
@orefalo: i have tried apollo-resolvers, i don't want wrap all of resolvers with a function. It look so ugly.
@orefalo: I posted a implement at here. Please take a look. Tks. :)
I opened PR at here to bring it to graphql-tools: https://github.com/apollographql/graphql-tools/pull/518
Directive can use as before & after resolver middlewares :D.
Hey! That PR really merged and release with version 2.13.0. So we can close this issues
cool! thank you @giautm
@giautm would be great if you could create a PR with a new example application using this feature 馃帀
Most helpful comment
@giautm would be great if you could create a PR with a new example application using this feature 馃帀