Class: GraphQL::Types::Int
- Inherits:
-
Schema::Scalar
- Object
- Schema::Member
- Schema::Scalar
- GraphQL::Types::Int
- Defined in:
- lib/graphql/types/int.rb
Overview
See Types::BigInt for handling integers outside 32-bit range.
Constant Summary collapse
- MIN =
: Integer
-(1 << 31) #: Integer
- MAX =
: Integer
(1 << 31) - 1
Constants included from Schema::Member::GraphQLTypeNames
Schema::Member::GraphQLTypeNames::Boolean, Schema::Member::GraphQLTypeNames::ID, Schema::Member::GraphQLTypeNames::Int
Instance Attribute Summary
Attributes included from Schema::Member::BaseDSLMethods
#default_graphql_name, #graphql_name
Attributes included from Schema::Member::RelayShortcuts
#connection_type, #connection_type_class, #edge_type, #edge_type_class
Attributes included from Schema::Member::HasAstNode
Class Method Summary collapse
-
.coerce_input(value, ctx) ⇒ Object
: (untyped value, GraphQL::Query::Context ctx) -> untyped.
-
.coerce_result(value, ctx) ⇒ Object
: (untyped value, GraphQL::Query::Context ctx) -> untyped.
Methods inherited from Schema::Scalar
default_scalar, default_scalar?, kind, specified_by_url, validate_non_null_input
Methods included from Schema::Member::ValidatesInput
#coerce_isolated_input, #coerce_isolated_result, #valid_input?, #valid_isolated_input?, #validate_input
Methods inherited from Schema::Member
Methods included from Schema::Member::BaseDSLMethods
#authorized?, #comment, #default_relay?, #description, #introspection, #introspection?, #mutation, #visible?
Methods included from Schema::FindInheritedValue
Methods included from Schema::Member::BaseDSLMethods::ConfigurationExtension
Methods included from Schema::Member::TypeSystemHelpers
#initialize, #kind, #list?, #non_null?, #to_list_type, #to_non_null_type, #to_type_signature
Methods included from Schema::Member::Scoped
#inherited, #reauthorize_scoped_objects, #scope_items
Methods included from Schema::Member::HasPath
Methods included from Schema::Member::HasAstNode
Methods included from Schema::Member::HasDirectives
add_directive, #directive, #directives, extended, get_directives, #inherited, #remove_directive, remove_directive
Class Method Details
.coerce_input(value, ctx) ⇒ Object
: (untyped value, GraphQL::Query::Context ctx) -> untyped
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/graphql/types/int.rb', line 15 def self.coerce_input(value, ctx) return if !value.is_a?(Integer) if value >= MIN && value <= MAX value else err = GraphQL::IntegerDecodingError.new(value) ctx.schema.type_error(err, ctx) end end |
.coerce_result(value, ctx) ⇒ Object
: (untyped value, GraphQL::Query::Context ctx) -> untyped
27 28 29 30 31 32 33 34 35 |
# File 'lib/graphql/types/int.rb', line 27 def self.coerce_result(value, ctx) value = value.to_i if value >= MIN && value <= MAX value else err = GraphQL::IntegerEncodingError.new(value, context: ctx) ctx.schema.type_error(err, ctx) end end |