Class: GraphQL::Schema::List
Overview
Represents a list type in the schema.
Wraps a Member as a list type.
Instance Attribute Summary
Attributes inherited from Wrapper
#of_type
Instance Method Summary
collapse
#coerce_isolated_input, #coerce_isolated_result, #valid_input?, #valid_isolated_input?, #validate_input
Methods inherited from Wrapper
#==, #initialize, #unwrap
#non_null?, #to_list_type, #to_non_null_type
#graphql_definition, #initialize_copy, #type_class
Instance Method Details
38
39
40
41
42
43
44
|
# File 'lib/graphql/schema/list.rb', line 38
def coerce_input(value, ctx)
if value.nil?
nil
else
ensure_array(value).map { |item| item.nil? ? item : of_type.coerce_input(item, ctx) }
end
end
|
#coerce_result(value, ctx) ⇒ Object
34
35
36
|
# File 'lib/graphql/schema/list.rb', line 34
def coerce_result(value, ctx)
value.map { |i| i.nil? ? nil : of_type.coerce_result(i, ctx) }
end
|
#graphql_name ⇒ Object
This is for introspection, where it’s expected the name will be null
30
31
32
|
# File 'lib/graphql/schema/list.rb', line 30
def graphql_name
nil
end
|
#kind ⇒ GraphQL::TypeKinds::LIST
16
17
18
|
# File 'lib/graphql/schema/list.rb', line 16
def kind
GraphQL::TypeKinds::LIST
end
|
#list? ⇒ true
21
22
23
|
# File 'lib/graphql/schema/list.rb', line 21
def list?
true
end
|
#to_graphql ⇒ Object
11
12
13
|
# File 'lib/graphql/schema/list.rb', line 11
def to_graphql
@of_type.graphql_definition.to_list_type
end
|
#to_type_signature ⇒ Object
25
26
27
|
# File 'lib/graphql/schema/list.rb', line 25
def to_type_signature
"[#{@of_type.to_type_signature}]"
end
|
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/graphql/schema/list.rb', line 46
def validate_non_null_input(value, ctx)
result = GraphQL::Query::InputValidationResult.new
ensure_array(value).each_with_index do |item, index|
item_result = of_type.validate_input(item, ctx)
if !item_result.valid?
result.merge_result!(index, item_result)
end
end
result
end
|