2

if my server responds with results like those:

row = {
   id: value,
   name: value,
   height: value,
   categories: [{id: "1", name: "name 1" },{id: "2", name: "name 2"},{id: "3", name: "name 3"},{id: "4", name: "name 4"}]
}

how can I use this information to populate my ReferenceArrayField ChipFields without requiring extra calls against /categories?filter={ids: [ ]} ?

Michail Michailidis
  • 11,792
  • 6
  • 63
  • 106

1 Answers1

2

We don't support this scenario currently. In AOR, categories should be a distinct resource and the resource you're showing should only references the categories ids.

If you do have a distinct resource for categories, then your restClient should cleanup the resource referencing categories and only includes their ids

Gildas Garcia
  • 6,966
  • 3
  • 15
  • 29
  • I don't understand why this isn't supported considering the performance implication behind making additional network requests. – Joseph Persico Mar 16 '18 at 19:31
  • 1
    @JosephPersie after searching Redux a bit it seems it works well with flattened data and it has big difficulties with hierarchical/ embedded data.. I bet this is why aor took that direction.. you can use a plugin like this: https://github.com/MhdSyrwan/aor-embedded-array but it doesn't work for single objects - it works only with arrays of objects even though I requested that here it seems out of scope for the creator: https://github.com/MhdSyrwan/aor-embedded-array/issues/5 – Michail Michailidis Mar 17 '18 at 10:34
  • @MichailMichailidis Thanks for the recommendation. I seem to have resolved the issue and have posted my finding in the github issue here: https://github.com/marmelab/admin-on-rest/issues/1662 – Joseph Persico Mar 18 '18 at 21:37