Class: GraphQL::Schema::NonNull

Inherits:
Wrapper
  • Object
show all
Includes:
Member::ValidatesInput
Defined in:
lib/graphql/schema/non_null.rb

Overview

Represents a non null type in the schema. Wraps a Member when it is required.

See Also:

  • {Schema{Schema::Member{Schema::Member::TypeSystemHelpers{Schema::Member::TypeSystemHelpers#to_non_null_type}

Instance Attribute Summary

Attributes inherited from Wrapper

#of_type

Instance Method Summary collapse

Methods included from Member::ValidatesInput

#coerce_isolated_input, #coerce_isolated_result, #valid_input?, #valid_isolated_input?

Methods inherited from Wrapper

#==, #initialize, #unwrap

Methods included from Member::TypeSystemHelpers

#to_list_type, #to_non_null_type

Methods included from Member::CachedGraphQLDefinition

#graphql_definition, #initialize_copy, #type_class

Constructor Details

This class inherits a constructor from GraphQL::Schema::Wrapper

Instance Method Details

#coerce_input(value, ctx) ⇒ Object


53
54
55
# File 'lib/graphql/schema/non_null.rb', line 53

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

#coerce_result(value, ctx) ⇒ Object


57
58
59
# File 'lib/graphql/schema/non_null.rb', line 57

def coerce_result(value, ctx)
  of_type.coerce_result(value, ctx)
end

#descriptionObject

This is for implementing introspection


62
63
64
# File 'lib/graphql/schema/non_null.rb', line 62

def description
  nil
end

#graphql_nameObject

This is for introspection, where it's expected the name will be null


49
50
51
# File 'lib/graphql/schema/non_null.rb', line 49

def graphql_name
  nil
end

#inspectObject


34
35
36
# File 'lib/graphql/schema/non_null.rb', line 34

def inspect
  "#<#{self.class.name} @of_type=#{@of_type.inspect}>"
end

#kindGraphQL::TypeKinds::NON_NULL

Returns:

  • (GraphQL::TypeKinds::NON_NULL)

16
17
18
# File 'lib/graphql/schema/non_null.rb', line 16

def kind
  GraphQL::TypeKinds::NON_NULL
end

#list?Boolean

Returns True if this type wraps a list type.

Returns:

  • (Boolean)

    True if this type wraps a list type


26
27
28
# File 'lib/graphql/schema/non_null.rb', line 26

def list?
  @of_type.list?
end

#non_null?true

Returns:

  • (true)

21
22
23
# File 'lib/graphql/schema/non_null.rb', line 21

def non_null?
  true
end

#to_graphqlObject


11
12
13
# File 'lib/graphql/schema/non_null.rb', line 11

def to_graphql
  @of_type.graphql_definition.to_non_null_type
end

#to_type_signatureObject


30
31
32
# File 'lib/graphql/schema/non_null.rb', line 30

def to_type_signature
  "#{@of_type.to_type_signature}!"
end

#validate_input(value, ctx) ⇒ Object


38
39
40
41
42
43
44
45
46
# File 'lib/graphql/schema/non_null.rb', line 38

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