Class: GraphQL::Schema::NonNull
Overview
Represents a non null type in the schema.
Wraps a Member when it is required.
Instance Attribute Summary
Attributes inherited from Wrapper
#of_type
Instance Method Summary
collapse
#coerce_isolated_input, #coerce_isolated_result, #valid_input?, #valid_isolated_input?
Methods inherited from Wrapper
#==, #initialize, #unwrap
#initialize, #to_list_type, #to_non_null_type
Instance Method Details
49
50
51
52
53
54
55
|
# File 'lib/graphql/schema/non_null.rb', line 49
def coerce_input(value, ctx)
if value.nil?
raise GraphQL::ExecutionError, "`null` is not a valid input for `#{to_type_signature}`, please provide a value for this argument."
end
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
|
#description ⇒ Object
This is for implementing introspection
62
63
64
|
# File 'lib/graphql/schema/non_null.rb', line 62
def description
nil
end
|
#graphql_name ⇒ Object
This is for introspection, where it's expected the name will be null
45
46
47
|
# File 'lib/graphql/schema/non_null.rb', line 45
def graphql_name
nil
end
|
30
31
32
|
# File 'lib/graphql/schema/non_null.rb', line 30
def inspect
"#<#{self.class.name} @of_type=#{@of_type.inspect}>"
end
|
#kind ⇒ GraphQL::TypeKinds::NON_NULL
12
13
14
|
# File 'lib/graphql/schema/non_null.rb', line 12
def kind
GraphQL::TypeKinds::NON_NULL
end
|
#list? ⇒ Boolean
22
23
24
|
# File 'lib/graphql/schema/non_null.rb', line 22
def list?
@of_type.list?
end
|
#non_null? ⇒ true
17
18
19
|
# File 'lib/graphql/schema/non_null.rb', line 17
def non_null?
true
end
|
#to_type_signature ⇒ Object
26
27
28
|
# File 'lib/graphql/schema/non_null.rb', line 26
def to_type_signature
"#{@of_type.to_type_signature}!"
end
|
34
35
36
37
38
39
40
41
42
|
# File 'lib/graphql/schema/non_null.rb', line 34
def validate_input(value, ctx, max_errors: nil)
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, max_errors: max_errors)
end
end
|