react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Possibility to pass additional data in the server response for getList

Open AntoineCrb opened this issue 1 year ago • 1 comments

An API might want to send additional data since all the data isn't send when using pagination

The useListContext() hook, as documented here, provides only data and total, not additional values sent back by getList()

The solutions that could be implemented to allow this mechanism are not practical at all (feel free to explain it here if you were to find one)

I also found this stackoverflow question that raises the same issue


Here is an example using chips to show a summary of all the data (not working since the feature doesn't exist) : Screenshot 2024-01-07 223943

AntoineCrb avatar Jan 07 '24 21:01 AntoineCrb

This has been proposed in the past (see https://github.com/marmelab/react-admin/pull/4834), but the added complexity is non-negligible.

It's also possible to do it with a custom data provider method (e.g. getListMetadata). Your data provider can store the metadata from a getList response in a local cache, and return it in the getListMetadata response.

I'm open to a PR implementing this feature, but it's not an easy task, and probably not something the core team will woek on in the forseeable future.

fzaninotto avatar Jan 08 '24 13:01 fzaninotto