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.0.0 lib/graphql/types/big_int.rb
graphql-1.13.9 lib/graphql/types/big_int.rb
graphql-1.12.24 lib/graphql/types/big_int.rb
graphql-1.13.8 lib/graphql/types/big_int.rb
graphql-1.13.7 lib/graphql/types/big_int.rb
graphql-1.13.6 lib/graphql/types/big_int.rb
graphql-1.13.5 lib/graphql/types/big_int.rb
graphql-1.13.4 lib/graphql/types/big_int.rb
graphql-1.13.3 lib/graphql/types/big_int.rb
graphql-1.12.23 lib/graphql/types/big_int.rb
graphql-1.13.2 lib/graphql/types/big_int.rb
graphql-1.13.1 lib/graphql/types/big_int.rb
graphql-1.12.22 lib/graphql/types/big_int.rb
graphql-1.13.0 lib/graphql/types/big_int.rb
graphql-1.12.21 lib/graphql/types/big_int.rb
graphql-1.12.20 lib/graphql/types/big_int.rb
graphql-1.12.19 lib/graphql/types/big_int.rb
graphql-1.12.18 lib/graphql/types/big_int.rb
graphql-1.12.17 lib/graphql/types/big_int.rb
graphql-1.12.16 lib/graphql/types/big_int.rb