Class: GraphQL::Schema::Scalar
- Extended by:
- Member::ValidatesInput
- Defined in:
- lib/graphql/schema/scalar.rb
Direct Known Subclasses
Types::BigInt, Types::Boolean, Types::Float, Types::ID, Types::ISO8601Date, Types::ISO8601DateTime, Types::Int, Types::JSON, Types::String
Constant Summary
Constants included from Member::HasDirectives
Member::HasDirectives::NO_DIRECTIVES
Constants included from Member::GraphQLTypeNames
Member::GraphQLTypeNames::Boolean, Member::GraphQLTypeNames::ID, Member::GraphQLTypeNames::Int
Instance Attribute Summary
Attributes included from Member::BaseDSLMethods
#default_graphql_name, #graphql_name
Attributes included from Member::RelayShortcuts
#connection_type, #connection_type_class, #edge_type, #edge_type_class
Attributes included from Member::HasAstNode
Class Method Summary collapse
-
.coerce_input(val, ctx) ⇒ Object
-
.coerce_result(val, ctx) ⇒ Object
-
.default_scalar(is_default = nil) ⇒ Object
-
.default_scalar? ⇒ Boolean
-
.kind ⇒ Object
-
.specified_by_url(new_url = nil) ⇒ Object
-
.validate_non_null_input(value, ctx, max_errors: nil) ⇒ Object
Methods included from Member::ValidatesInput
coerce_isolated_input, coerce_isolated_result, valid_input?, valid_isolated_input?, validate_input
Methods included from Member::BaseDSLMethods
#authorized?, #default_relay, #description, #introspection, #introspection?, #mutation, #name, #visible?
Methods included from Member::BaseDSLMethods::ConfigurationExtension
Methods included from Member::TypeSystemHelpers
#initialize, #kind, #list?, #non_null?, #to_list_type, #to_non_null_type, #to_type_signature
Methods included from Member::Scoped
Methods included from Member::HasPath
Methods included from Member::HasAstNode
Methods included from Member::HasDirectives
add_directive, #directive, #directives, get_directives, #inherited, #remove_directive, remove_directive
Class Method Details
.coerce_input(val, ctx) ⇒ Object
8 9 10 |
# File 'lib/graphql/schema/scalar.rb', line 8 def coerce_input(val, ctx) val end |
.coerce_result(val, ctx) ⇒ Object
12 13 14 |
# File 'lib/graphql/schema/scalar.rb', line 12 def coerce_result(val, ctx) val end |
.default_scalar(is_default = nil) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/graphql/schema/scalar.rb', line 32 def default_scalar(is_default = nil) if !is_default.nil? @default_scalar = is_default end @default_scalar end |
.default_scalar? ⇒ Boolean
39 40 41 |
# File 'lib/graphql/schema/scalar.rb', line 39 def default_scalar? @default_scalar ||= false end |
.kind ⇒ Object
16 17 18 |
# File 'lib/graphql/schema/scalar.rb', line 16 def kind GraphQL::TypeKinds::SCALAR end |
.specified_by_url(new_url = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/graphql/schema/scalar.rb', line 20 def specified_by_url(new_url = nil) if new_url @specified_by_url = new_url elsif defined?(@specified_by_url) @specified_by_url elsif superclass.respond_to?(:specified_by_url) superclass.specified_by_url else nil end end |
.validate_non_null_input(value, ctx, max_errors: nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/graphql/schema/scalar.rb', line 43 def validate_non_null_input(value, ctx, max_errors: nil) coerced_result = begin coerce_input(value, ctx) rescue GraphQL::CoercionError => err err rescue StandardError => err ctx.query.handle_or_reraise(err) end if coerced_result.nil? str_value = if value == Float::INFINITY "" else " #{GraphQL::Language.serialize(value)}" end Query::InputValidationResult.from_problem("Could not coerce value#{str_value} to #{graphql_name}") elsif coerced_result.is_a?(GraphQL::CoercionError) Query::InputValidationResult.from_problem(coerced_result., message: coerced_result., extensions: coerced_result.extensions) else nil end end |