mathematic-inc / ts-japi

A highly-modular (typescript-friendly)-framework agnostic library for serializing data to the JSON:API specification
Apache License 2.0
202 stars 15 forks source link

[BUG] incorrectly only a single include resources #68

Closed basz closed 11 months ago

basz commented 11 months ago

Describe the bug*

I'm not receiving all includes rources for a compount document

To Reproduce*

given a model like related like so

user - one2many > preferences user - one2many > member-organisations - o2o -> organisation

I have a fully loaded model for a single user, which has 3 member-organisations which each have an organisation.

In my serialised output I only see a single included organisation.

I am using include: ['organisation-members', 'preferences', 'organisation-members.organisation'] as serializer options.

If'v noticed adding organisation-members.organisation. as an additional (note the trailing dot) argument I will get two organisations included (but still not 3)...

Expected behavior*

All resources should be included

https://gist.github.com/basz/71e9296d468c867757ee7f8eee80677d

egmacke commented 11 months ago

I've had a look into what's going on and I'm pretty sure I've isolated the issue. It's related to how the serializer determines whether to recurse deeper, and I think there's a flaw in the logic.

Putting together a possible fix now.