Sha256: 2eb889239c1924f6366cbf5410d3ba47db0ded6ddb14cd8429db7e34fd16d36c

Contents?: true

Size: 802 Bytes

Versions: 188

Compression:

Stored size: 802 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  class UnauthorizedFieldError < GraphQL::UnauthorizedError
    # @return [Field] the field that failed the authorization check
    attr_accessor :field

    def initialize(message = nil, object: nil, type: nil, context: nil, field: nil)
      if message.nil? && [field, type].any?(&:nil?)
        raise ArgumentError, "#{self.class.name} requires either a message or keywords"
      end

      @field = field
      message ||= begin
        if object
          "An instance of #{object.class} failed #{type.name}'s authorization check on field #{field.name}"
        else
          "Failed #{type.name}'s authorization check on field #{field.name}"
        end
      end
      super(message, object: object, type: type, context: context)
    end
  end
end

Version data entries

188 entries across 188 versions & 2 rubygems

Version Path
graphql-2.1.4 lib/graphql/unauthorized_field_error.rb
graphql-1.13.20 lib/graphql/unauthorized_field_error.rb
graphql-2.1.3 lib/graphql/unauthorized_field_error.rb
graphql-2.1.2 lib/graphql/unauthorized_field_error.rb
graphql-2.1.1 lib/graphql/unauthorized_field_error.rb
graphql-2.1.0 lib/graphql/unauthorized_field_error.rb
graphql-2.0.27 lib/graphql/unauthorized_field_error.rb
graphql-2.0.26 lib/graphql/unauthorized_field_error.rb
graphql-2.0.25 lib/graphql/unauthorized_field_error.rb
graphql-2.0.24 lib/graphql/unauthorized_field_error.rb
graphql-2.0.23 lib/graphql/unauthorized_field_error.rb
graphql-2.0.22 lib/graphql/unauthorized_field_error.rb
graphql-2.0.21 lib/graphql/unauthorized_field_error.rb
graphql-2.0.20 lib/graphql/unauthorized_field_error.rb
graphql-2.0.17.2 lib/graphql/unauthorized_field_error.rb
graphql-2.0.17.1 lib/graphql/unauthorized_field_error.rb
graphql-2.0.19 lib/graphql/unauthorized_field_error.rb
graphql-2.0.18 lib/graphql/unauthorized_field_error.rb
graphql-2.0.17 lib/graphql/unauthorized_field_error.rb
graphql-1.13.19 lib/graphql/unauthorized_field_error.rb