Sha256: b3def5bb5b9f98a897e4af5a1671b8be24201234f21767bf99aad8184a2c5983

Contents?: true

Size: 583 Bytes

Versions: 120

Compression:

Stored size: 583 Bytes

Contents

# frozen_string_literal: true

module GraphQL
  module Types
    class BigInt < GraphQL::Schema::Scalar
      description "Represents non-fractional signed whole numeric values. Since the value may exceed the size of a 32-bit integer, it's encoded as a string."

      def self.coerce_input(value, _ctx)
        value && parse_int(value)
      rescue ArgumentError
        nil
      end

      def self.coerce_result(value, _ctx)
        value.to_i.to_s
      end

      def self.parse_int(value)
        value.is_a?(Numeric) ? value : Integer(value, 10)
      end
    end
  end
end

Version data entries

120 entries across 120 versions & 2 rubygems

Version Path
graphql-2.4.4 lib/graphql/types/big_int.rb
graphql-2.4.3 lib/graphql/types/big_int.rb
graphql-2.4.2 lib/graphql/types/big_int.rb
graphql-2.4.1 lib/graphql/types/big_int.rb
graphql-2.4.0 lib/graphql/types/big_int.rb
graphql-2.3.20 lib/graphql/types/big_int.rb
graphql-2.3.19 lib/graphql/types/big_int.rb
graphql-2.3.18 lib/graphql/types/big_int.rb
graphql-2.3.17 lib/graphql/types/big_int.rb
graphql-2.3.16 lib/graphql/types/big_int.rb
graphql-2.3.15 lib/graphql/types/big_int.rb
graphql-2.3.14 lib/graphql/types/big_int.rb
graphql-2.3.13 lib/graphql/types/big_int.rb
graphql-2.3.12 lib/graphql/types/big_int.rb
graphql-2.3.11 lib/graphql/types/big_int.rb
graphql-2.3.10 lib/graphql/types/big_int.rb
graphql-2.2.16 lib/graphql/types/big_int.rb
graphql-2.1.13 lib/graphql/types/big_int.rb
graphql-2.3.9 lib/graphql/types/big_int.rb
graphql-2.3.8 lib/graphql/types/big_int.rb