diff --git a/request_test.go b/request_test.go index cf7eef2..69df26a 100644 --- a/request_test.go +++ b/request_test.go @@ -133,6 +133,10 @@ func TestUnmarshalNestedRelationshipsSideloaded(t *testing.T) { if len(out.CurrentPost.Comments) != 2 { t.Fatalf("Wrong number of comments") } + + if out.CurrentPost.Comments[0].Body != "foo" { + t.Fatalf("Comment body not set") + } } func unmarshalSamplePayload() (*Blog, error) { diff --git a/response.go b/response.go index 8f3f3ff..4229d74 100644 --- a/response.go +++ b/response.go @@ -178,10 +178,10 @@ func visitModelNode(model interface{}, sideload bool) (*Node, []*Node, error) { return false } } else { - relationship, _, err := visitModelNode(fieldValue.Interface(), sideload) + relationship, inc, err := visitModelNode(fieldValue.Interface(), sideload) if err == nil { if sideload { - included = append(included, relationship) + included = append(included, inc...) node.Relationships[args[1]] = &RelationshipOneNode{Data: toShallowNode(relationship)} } else { node.Relationships[args[1]] = &RelationshipOneNode{Data: relationship}