Skip to content
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

New Feature: Pluggable Middleware (for AAA among other) #20

Closed
orefalo opened this issue Nov 30, 2017 · 13 comments
Closed

New Feature: Pluggable Middleware (for AAA among other) #20

orefalo opened this issue Nov 30, 2017 · 13 comments

Comments

@orefalo
Copy link

orefalo commented Nov 30, 2017

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.

@giautm
Copy link
Contributor

giautm commented Nov 30, 2017

I think there is a good example about authentication via directives: https://github.com/chenkie/graphql-auth

@orefalo
Copy link
Author

orefalo commented Nov 30, 2017

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.

@orefalo
Copy link
Author

orefalo commented Nov 30, 2017

Went over your code... then found this issue chenkie/graphql-auth#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 orefalo changed the title New Feature: Pluggable Authentication & Authorization New Feature: Pluggable Middleware (for AAA among other) Nov 30, 2017
@giautm
Copy link
Contributor

giautm commented Nov 30, 2017

@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

@orefalo
Copy link
Author

orefalo commented Nov 30, 2017

@giautm I would gladly look at some samples ;-) No idea how to get it done.

@orefalo
Copy link
Author

orefalo commented Nov 30, 2017

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

@giautm
Copy link
Contributor

giautm commented Dec 1, 2017

@orefalo: i have tried apollo-resolvers, i don't want wrap all of resolvers with a function. It look so ugly.

@giautm
Copy link
Contributor

giautm commented Dec 1, 2017

@orefalo: I posted a implement at here. Please take a look. Tks. :)

@giautm
Copy link
Contributor

giautm commented Dec 4, 2017

I opened PR at here to bring it to graphql-tools: ardatan/graphql-tools#518

Directive can use as before & after resolver middlewares :D.

@giautm
Copy link
Contributor

giautm commented Dec 13, 2017

Hey! That PR really merged and release with version 2.13.0. So we can close this issues

@orefalo
Copy link
Author

orefalo commented Dec 13, 2017

cool! thank you @giautm

@orefalo orefalo closed this as completed Dec 13, 2017
@schickling
Copy link
Contributor

@giautm would be great if you could create a PR with a new example application using this feature 🎉

@Urigo
Copy link
Collaborator

Urigo commented Mar 29, 2022

Hey, @Urigo from The Guild here!

You might know us from projects such as graphql-code-generator, envelop or graphql-tools.

For a long time we thought that the Javascript ecosystem is still missing a lightweight cross-platform, but still highly customizable GraphQL Server.

In the past the awesome Prisma team took on that great challenge and now we are happy to announce that we are continuing them and just released GraphQL Yoga 2.0 - Build fast, extensible, and batteries-included (Subscriptions, Serverless, File uploads support) GraphQL APIs in Node.js 🚀

And regarding the issue here, Yoga uses the Envelop plugin system under the hood which has integrations and plugins and hooks that are more powerful then GraphQL Middleware.

We have been working a long time on version 2.0 and have been using it in our clients projects for a few months now and shared a couple of alpha cycles here.
Thank you all for your feedback and suggestions, you made this release possible!

Please try Yoga out again, give us feedback and help us spread the word on the new release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants