Sha256: d933479c55215bc553f1c84b27ebb552a02e0f6bf6ce6922397c59f8214dca92

Contents?: true

Size: 829 Bytes

Versions: 18

Compression:

Stored size: 829 Bytes

Contents

module GraphQL
  # A non-null type wraps another type.
  #
  # Get the underlying type with {#unwrap}
  class NonNullType < GraphQL::BaseType
    include GraphQL::BaseType::ModifiesAnotherType

    attr_reader :of_type
    def initialize(of_type:)
      @of_type = of_type
    end

    def name
      "Non-Null"
    end

    def valid_input?(value)
      validate_input(value).valid?
    end

    def validate_input(value)
      if value.nil?
        result = GraphQL::Query::InputValidationResult.new
        result.add_problem("Expected value to not be null")
        result
      else
        of_type.validate_input(value)
      end
    end

    def coerce_input(value)
      of_type.coerce_input(value)
    end

    def kind
      GraphQL::TypeKinds::NON_NULL
    end

    def to_s
      "#{of_type.to_s}!"
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
graphql-0.18.4 lib/graphql/non_null_type.rb
graphql-0.18.3 lib/graphql/non_null_type.rb
graphql-0.18.2 lib/graphql/non_null_type.rb
graphql-0.18.1 lib/graphql/non_null_type.rb
graphql-0.18.0 lib/graphql/non_null_type.rb
graphql-0.17.2 lib/graphql/non_null_type.rb
graphql-0.17.1 lib/graphql/non_null_type.rb
graphql-0.17.0 lib/graphql/non_null_type.rb
graphql-0.16.1 lib/graphql/non_null_type.rb
graphql-0.16.0 lib/graphql/non_null_type.rb
graphql-0.15.3 lib/graphql/non_null_type.rb
graphql-0.15.2 lib/graphql/non_null_type.rb
graphql-0.14.2 lib/graphql/non_null_type.rb
graphql-0.15.1 lib/graphql/non_null_type.rb
graphql-0.15.0 lib/graphql/non_null_type.rb
graphql-0.14.1 lib/graphql/non_null_type.rb
graphql-0.14.0 lib/graphql/non_null_type.rb
graphql-0.13.0 lib/graphql/non_null_type.rb