raphiniert-com / ra-data-postgrest

react admin client for postgREST
MIT License
111 stars 34 forks source link

Support 'Accept: 'text/csv'' response? #157

Open skoschik opened 3 months ago

skoschik commented 3 months ago

Hi,

First off, thank you for the great work on this data provider for PostgREST! It's been a tremendous asset in my project. I would like to request a feature or get your thoughts on supporting the 'Accept: text/csv' header and its response in this provider. PostgREST offers the ability to export data in CSV format by including this header, which could be really useful for exporting lists directly from React Admin.

Background: I've added the 'Accept: text/csv' header using the meta property that ra-data-postgrest provides via getList. This works great for exporting lists in CSV format directly from PostgREST, but...

Issue: I'm encountering difficulties with the response handling. The current implementation expects JSON responses, which is incompatible when receiving CSV data from the API.

Feature Request: Does CSV handling make sense to implement within this library, or do you have guidance on how to achieve it?

Thank you again for your efforts on this project! Looking forward to your insights.

scheiblr commented 3 months ago

Hey @skoschik,

thanks for opening this issue. Making the DP capable of handling the CSV export functionality of PostgREST sounds like a decent idea and I believe it could be realized, but is a question of effort which I currently do not know. What I can think of right now, should be doable:

If you want to give it a try, go for it ;)

Anyways, just for interest and understanding: may I ask you, how you are actually using the DP as you need would like rely on that feature, as the react-admin frontend list-component has already a csv export?

Kind regards

skoschik commented 2 months ago

Hey thanks for the feedback @scheiblr!

Great info and I'll give it a closer look soon.

Also regarding my use case: I believe react-admin CSV exporter does the JSON to CSV serialization on the frontend. For larger datasets it was just too slow (sending and having frontend serialize)