diff --git a/lib/graphiti/hash_renderer.rb b/lib/graphiti/hash_renderer.rb index 64bcc6ca..a7410232 100644 --- a/lib/graphiti/hash_renderer.rb +++ b/lib/graphiti/hash_renderer.rb @@ -70,8 +70,8 @@ def to_hash(fields: nil, include: {}, name_chain: [], graphql: false) serializers = v.send(:resources) name = graphql ? k.to_s.camelize(:lower) : k - name_chain = name_chain.dup - name_chain << k unless name_chain.last == k + subchain = name_chain.dup + subchain << k unless subchain.last == k unless remote_resource? && serializers.nil? payload = if serializers.is_a?(Array) @@ -86,7 +86,7 @@ def to_hash(fields: nil, include: {}, name_chain: [], graphql: false) end end else - serializers.to_hash(fields: fields, include: nested_include, graphql: graphql, name_chain: name_chain) + serializers.to_hash(fields: fields, include: nested_include, graphql: graphql, name_chain: subchain) end attrs[name.to_sym] = payload