Related Resources
Last updated
Last updated
Endpoints frequently return more than one resource type in a single response. For instance, a request for a single author
may also include the author's books
.
Because different backends return related resources in many different ways, Redux Resource couldn't possibly include a single built-in solution that works for every API. Instead, can be used to support related resources in a way that works for your specific backend.
The rest of this guide will describe supporting related resources for the following technologies:
Would you like us to include a guide for a technology not listed here? Just !
The works well with data. Refer to the Included Resources Plugin documentation to familiarize yourself with its API.
Here's an example demonstrating using Redux Resource with normalizr on a slice that has the Included Resources Plugin:
Filter the Array of included
resources to find just the resources whose
JSON API type
matches the resourceType
of the slice.
You would also want to place the each individual resource's meta
into the meta
section of the slice.
If you're using the library, you can perform this normalization in the onSucceeded
callback:
At the moment, the easiest way to support JSON API compound documents is to use the library, and then follow the normalizr guide above.
An official JSON API plugin is being . We would love your help!
If you would like to try your hand at writing a JSON API relationship plugin, here are a few tips. In short, you would need to interpet the included
member of a . This would likely work in 2 steps:
Use to add those resources to the slice.
We would love to support GraphQL, but we need your help. If you're interested in helping out, please to chat about it. Thank you!