Sha256: c072a53e7462b197cbff16b93c49c4883654630781930e9bd79abf40c25bc827

Contents?: true

Size: 1.14 KB

Versions: 122

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true
module GraphQL
  # This error is raised when `Types::Int` is asked to return a value outside of 32-bit integer range.
  #
  # For values outside that range, consider:
  #
  # - `ID` for database primary keys or other identifiers
  # - `GraphQL::Types::BigInt` for really big integer values
  #
  # @see GraphQL::Types::Int which raises this error
  class IntegerEncodingError < GraphQL::RuntimeTypeError
    # The value which couldn't be encoded
    attr_reader :integer_value

    # @return [GraphQL::Schema::Field] The field that returned a too-big integer
    attr_reader :field

    # @return [Array<String, Integer>] Where the field appeared in the GraphQL response
    attr_reader :path

    def initialize(value, context:)
      @integer_value = value
      @field = context[:current_field]
      @path = context[:current_path]
      message = "Integer out of bounds: #{value}".dup
      if @path
        message << " @ #{@path.join(".")}"
      end
      if @field
        message << " (#{@field.path})"
      end
      message << ". Consider using ID or GraphQL::Types::BigInt instead."
      super(message)
    end
  end
end

Version data entries

122 entries across 122 versions & 2 rubygems

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