palkan/action_policy-graphql

Allow to use proc for authorized_scope

dmitry opened this issue · 1 comments

Allow to use proc for authorized_scope. Specifically it might be helpful if you would like to pass some ids via scope_options.

  field :events, EventType.connection_type, null: false, authorized_scope: -> object { {with: CustomEventPolicy, scope_options: {city_id: object.id}} }

Personally, I don't like the idea of using procs in DSLs. That suffers readability. If something couldn't be expressed via static options, it should be done differently.

For example, you can define a resolver method:

def events
  authorized_scope object.events, with: CustomEventPolicy, scope_options: {city_id: object.id}
end