Sha256: ca393631175c55312be892871106e62e1417129f5327efa239abcd681e818309

Contents?: true

Size: 828 Bytes

Versions: 7

Compression:

Stored size: 828 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  class Schema
    class Scalar < GraphQL::Schema::Member
      class << self
        def coerce_input(val, ctx)
          raise NotImplementedError, "#{self.name}.coerce_input(val, ctx) must prepare GraphQL input (#{val.inspect}) for Ruby processing"
        end

        def coerce_result(val, ctx)
          raise NotImplementedError, "#{self.name}.coerce_result(val, ctx) must prepare Ruby value (#{val.inspect}) for GraphQL response"
        end

        def to_graphql
          type_defn = GraphQL::ScalarType.new
          type_defn.name = graphql_name
          type_defn.description = description
          type_defn.coerce_result = method(:coerce_result)
          type_defn.coerce_input = method(:coerce_input)
          type_defn
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
graphql-1.8.0.pre7 lib/graphql/schema/scalar.rb
graphql-1.8.0.pre6 lib/graphql/schema/scalar.rb
graphql-1.8.0.pre5 lib/graphql/schema/scalar.rb
graphql-1.8.0.pre4 lib/graphql/schema/scalar.rb
graphql-1.8.0.pre3 lib/graphql/schema/scalar.rb
graphql-1.8.0.pre2 lib/graphql/schema/scalar.rb
graphql-1.8.0.pre1 lib/graphql/schema/scalar.rb