Sha256: 9a546572413082b531588c24876b69dd96497897fe26b1e07222f28bb0953d16
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
# frozen_string_literal: true module GraphQL class Schema class Scalar < GraphQL::Schema::Member extend GraphQL::Schema::Member::ValidatesInput class << self def coerce_input(val, ctx) val end def coerce_result(val, ctx) val end def kind GraphQL::TypeKinds::SCALAR end 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 def default_scalar(is_default = nil) if !is_default.nil? @default_scalar = is_default end @default_scalar end def default_scalar? @default_scalar ||= false end def validate_non_null_input(value, ctx) coerced_result = begin ctx.query.with_error_handling do coerce_input(value, ctx) end rescue GraphQL::CoercionError => err 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, message: coerced_result.message, extensions: coerced_result.extensions) else nil end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
graphql-2.0.2 | lib/graphql/schema/scalar.rb |
graphql-2.0.1 | lib/graphql/schema/scalar.rb |