Skip to content

Conversation

@olivierwilkinson
Copy link
Owner

@olivierwilkinson olivierwilkinson commented Jan 9, 2023

There is a bug where modifying results that are nested within a list
result does not work, the result is always undefined.

The reason modifying results that are within a list does not work is
that the nested relation is found on each item of the list rather than
the list itself, so when we get the relation by name the result is
always undefined.

When a next function is returning a relation that is nested within a
list combine all the relation values into a single flat array. This
means middleware only has to handle flat arrays of results which makes
modifying the result before it is returned easier. If the result's
parent is needed then it is possible to go through the parent middleware
and traverse that relation; only a single depth of relation needs to be
traversed as the middleware will be called for each layer.

Add more specific tests to ensure the problem is fixed at various
depths.

There is a bug where modifying results that are nested within a list
result does not work, the result is always undefined.

The reason modifying results that are within a list does not work is
that the nested relation is found on each item of the list rather than
the list itself, so when we get the relation by name the result is
always `undefined`.

When a `next` function is returning a relation that is nested within a
list combine all the relation values into a single flat array. This
means middleware only has to handle flat arrays of results which makes
modifying the result before it is returned easier. If the result's
parent is needed then it is possible to go through the parent middleware
and traverse that relation; only a single depth of relation needs to be
traversed as the middleware will be called for each layer.

Add more specific tests to ensure the problem is fixed at various
depths.
@olivierwilkinson olivierwilkinson merged commit 753bf7b into main Jan 9, 2023
@olivierwilkinson olivierwilkinson deleted the fix-deeply-nested-value-updates branch January 9, 2023 18:28
@github-actions
Copy link

github-actions bot commented Jan 9, 2023

🎉 This PR is included in version 1.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants