Skip to content

Define methods directly for "GraphQL Type authorization"

The following discussion from !25724 (merged) should be addressed:

  • @godfat started a discussion:

    I just realized that we don't need to build a lambda for build_checker at all? We can just call it as a method.

    verify(ctx[:current_user], resolved_obj)

    And define it like:

    def verify(current_user, object)
      # everything in the previous build_checker
    end

    We don't need that check lambda either:

    def check(current_user, object)
      authorizations.all? do |ability|
        Ability.allowed?(current_user, ability, object)
      end
    end

    I wrote those as lambdas because I was trying to follow the old code, but it looks like we really don't need that. Is it right?

    Anyway, I think we can do this later. This is already well done and not exactly related to this merge request.