Sha256: 44f931b3413a82ad2f12a43e4cdd0b8585fa8e5d3f9b5de08412b0c41fe226db

Contents?: true

Size: 831 Bytes

Versions: 13

Compression:

Stored size: 831 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  class UnauthorizedError < GraphQL::Error
    # @return [Object] the application object that failed the authorization check
    attr_reader :object

    # @return [Class] the GraphQL object type whose `.authorized?` method was called (and returned false)
    attr_reader :type

    # @return [GraphQL::Query::Context] the context for the current query
    attr_reader :context

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

      @object = object
      @type = type
      @context = context
      message ||= "An instance of #{object.class} failed #{type.name}'s authorization check"
      super(message)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
graphql-1.8.17 lib/graphql/unauthorized_error.rb
graphql-1.8.16 lib/graphql/unauthorized_error.rb
graphql-1.8.15 lib/graphql/unauthorized_error.rb
graphql-1.8.14 lib/graphql/unauthorized_error.rb
graphql-1.8.13 lib/graphql/unauthorized_error.rb
graphql-1.8.12 lib/graphql/unauthorized_error.rb
graphql-1.8.11 lib/graphql/unauthorized_error.rb
graphql-1.8.10 lib/graphql/unauthorized_error.rb
graphql-1.8.9 lib/graphql/unauthorized_error.rb
graphql-1.8.8 lib/graphql/unauthorized_error.rb
graphql-1.8.7 lib/graphql/unauthorized_error.rb
graphql-1.8.6 lib/graphql/unauthorized_error.rb
graphql-1.8.5 lib/graphql/unauthorized_error.rb