You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@WanjikuMac after some asking around I think I found a way of doing it
defmoduleSpender.Schema
…
defmiddleware(middleware,_field,%{identifier: :mutation})dotype=Absinthe.Schema.lookup_type(Spender.Schema,:mutation)auth_meta=Absinthe.Type.meta(type,:auth)#=> :any[{{Authorize,:call},[auth_meta]}|middleware]end
…
mutationdo@desc"Links an item to a LogSection"field:link_item,:log_sectiondoarg:input,non_null(:link_item_input)metaauth: :anyresolve&Resolvers.Planning.link_item/3endendend
Notice how now in mutations instead of adding middleware Middleware.Authorize, :any we can now just add meta to the field and use that for auth
Expected Behavior
All the Mutation objects on our schema require that a user is authenticated for the operation, Instead of applying the Authorization middleware per a field every time we make a new mutation we should use the
middleware/3
callback to apply it to all mutation fields see here https://github.com/absinthe-graphql/absinthe/blob/master/guides/middleware-and-plugins.md#2-using-the-middleware3-callback-in-your-schema on how to use itActual Behavior
At the moment the Authorization middleware is applied individually to every mutation object.
Acceptance Criteria
The Authorization middleware should be applied using the middleware/3 callback
Steps to Reproduce the Problem
Specifications
The text was updated successfully, but these errors were encountered: