Middleware Authorization
Learn how to add authorization checks using middleware.
We'll cover the following
Authorization middleware
Adding authorization checks inside all our resolvers will produce clutter, so let’s build middleware to handle this problem fully. As you may recall, we have two choices for how to apply middleware:
.We can use the middleware/2
macro to configure individual fields or the middleware/3
callback function to take a pattern-based approach. Different fields have slightly different authorization conditions, so we will use the middleware/2
macro to annotate them individually. Using this middleware should look something like this:
Get hands-on with 1400+ tech skills courses.