-
-
Notifications
You must be signed in to change notification settings - Fork 674
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
feat: Middleware Decorator to Resolver #1297
feat: Middleware Decorator to Resolver #1297
Conversation
@xcfox does this work with |
a190360
to
f50d1d0
Compare
6e1c81e
to
c8d2e2d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1297 +/- ##
==========================================
- Coverage 95.50% 95.40% -0.10%
==========================================
Files 113 114 +1
Lines 1847 1873 +26
Branches 364 328 -36
==========================================
+ Hits 1764 1787 +23
- Misses 83 86 +3 ☔ View full report in Codecov by Sentry. |
Now it should be ready to be merged! |
* ✨feat(Authorized): decorator to resolver * ✨feat(decorators/UseMiddleware): middleware decorator to Resolver * ✨feat(decorators): createMiddlewareDecorator * 🐞fix(tests/middlewares): add @resolver() to LocalResolver * 🐞fix(decorators): export createMiddlewareDecorator * Rename create decorator method * Add changelog * Add comments for cleanup in tests * Add missing shim for createClassMiddlewareDecorator * Update docs to reflect new class-defined auth and middlewares * Rename createResolverClassMiddlewareDecorator and update changelog * Update examples to use resolver class scoped middleware --------- Co-authored-by: Michał Lytek <michal.wojciech.lytek@gmail.com>
This PR implements #620 and a part of #200
This PR enhances
@UseMiddleware()
and@Authorized()
, now we can put them directly on the resolver so that we can avoid repeating on each method.Use
@UseMiddleware()
like so:Middlewares will be called in the order of global, resolver, field.
Use
@Authorized()
like so:When you set
roles
for both the field and the resolver, the roles will be overwritten by the field's@Authorized()
I also make a function
createMiddlewareDecorator
to help you create custom middlewares, it is similar tocreateMethodDecorator
, but can be placed on resolver