Feature/fetch nested relationships #14
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the nested relationship fetching described in #11. The
relatedconfig option now accepts an object within which a property of theModelin question may be used as a key, and its value is another object whose key/value pairs aretype: 'property'format. This informs which nested relationships should be requested using dot notation in the request to the API, like so:To-Do:
A strategy must be implemented to ensure we don’t ever fall into an infinite loop. One such strategy is described in the issue comments, but I’m open to ideas.
I implemented this with a single happy-path test. Additional tests (and, probably, work) is needed to ensure this feature can handle mixed relationship definitions (e.g. an array of objects and strings at the root of the
relatedconfig key), supplying a Boolean or an Array of properties as the value for the nestedtypekey (e.g.{ related: { author: { person: true } } }and{ related: { author: { person: [ 'roles', 'birthplace' ] } } }), and thoroughly testing the nested relationship limit described in the to-do item above.master.Since this branch is based on the branch for Fetch relationships in parallel #13, I’ve set the base for this PR to that branch. Once that PR is merged, this should be switched back to
master.