Sha256: f6effa87bc17bf794798f1472060b98d60158d18ed2fa8de564d064d63eb1302

Contents?: true

Size: 1.29 KB

Versions: 17

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true
module GraphQL
  module Introspection
    class InputValueType < Introspection::BaseObject
      graphql_name "__InputValue"
      description "Arguments provided to Fields or Directives and the input fields of an "\
                  "InputObject are represented as Input Values which describe their type and "\
                  "optionally a default value."
      field :name, String, null: false
      field :description, String, null: true
      field :type, GraphQL::Schema::LateBoundType.new("__Type"), null: false
      field :default_value, String, "A GraphQL-formatted string representing the default value for this input value.", null: true

      def default_value
        if @object.default_value?
          value = @object.default_value
          if value.nil?
            'null'
          else
            coerced_default_value = @object.type.coerce_result(value, @context)
            if @object.type.unwrap.is_a?(GraphQL::EnumType)
              if @object.type.list? 
                "[#{coerced_default_value.join(", ")}]"
              else
                coerced_default_value
              end
            else
              GraphQL::Language.serialize(coerced_default_value)
            end
          end
        else
          nil
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
graphql-1.9.21 lib/graphql/introspection/input_value_type.rb
graphql-1.9.20 lib/graphql/introspection/input_value_type.rb
graphql-1.9.19 lib/graphql/introspection/input_value_type.rb
graphql-1.9.18 lib/graphql/introspection/input_value_type.rb
graphql-1.9.17 lib/graphql/introspection/input_value_type.rb
graphql-1.9.16 lib/graphql/introspection/input_value_type.rb
graphql-1.9.15 lib/graphql/introspection/input_value_type.rb
graphql-1.9.14 lib/graphql/introspection/input_value_type.rb
graphql-1.9.13 lib/graphql/introspection/input_value_type.rb
graphql-1.9.12 lib/graphql/introspection/input_value_type.rb
graphql-1.9.11 lib/graphql/introspection/input_value_type.rb
graphql-1.9.10 lib/graphql/introspection/input_value_type.rb
graphql-1.9.9 lib/graphql/introspection/input_value_type.rb
graphql-1.9.8 lib/graphql/introspection/input_value_type.rb
graphql-1.9.7 lib/graphql/introspection/input_value_type.rb
graphql-1.9.6 lib/graphql/introspection/input_value_type.rb
graphql-1.9.5 lib/graphql/introspection/input_value_type.rb