9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/apollo-federation/field_set_serializer.rb', line 9
def serialize(fields, camelize: true)
case fields
when Hash
fields.map do |field, nested_selections|
"#{camelize(field, camelize)} { #{serialize(nested_selections, camelize: camelize)} }"
end.join(' ')
when Array
fields.map do |field|
serialize(field, camelize: camelize)
end.join(' ')
when Symbol, String
camelize(fields, camelize)
else
raise ArgumentError, "Unexpected field set type: #{fields.class}"
end
end
|