16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/graphql/executor.rb', line 16
def complete_value(context, field_type, resolved_object, selection_set)
return nil if resolved_object.nil?
resolved_object = resolved_object.value if resolved_object.is_a?(Celluloid::Future)
case field_type
when GraphQLNonNull
completed_object = complete_value(context, field_type.of_type, resolved_object, selection_set)
raise "Field error: expecting non null value" if completed_object.nil?
completed_object
when GraphQLList
resolved_object.map do |item|
complete_value(context, field_type.of_type, item, selection_set)
end
when GraphQLScalarType, GraphQLEnumType
field_type.serialize(resolved_object)
when GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType
field_type = field_type.resolve_type(resolved_object) if field_type.is_a?(GraphQLAbstractType)
selection_set.evaluate(context, field_type, resolved_object)
end
end
|