Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validateResponseFormat triggers error when calling a dataProvider custom method #8083

Closed
jvert opened this issue Aug 18, 2022 · 5 comments
Closed

Comments

@jvert
Copy link
Contributor

jvert commented Aug 18, 2022

If you implement a data provider with a custom method, then call that method as documented here then validateResponseFormat() throws an error if the returned object doesn't contain a 'data' key

The response to 'action' must be like { data: ... }, but the received response does not have a 'data' key. The dataProvider is probably wrong for 'action'.

I think if it's a custom method, there should not be any validation of the returned object (how could react-admin know?)

Otherwise, maybe the type of DataProvider should be typed better than [key: string]: any

@antoinefricker
Copy link
Contributor

antoinefricker commented Aug 19, 2022

Thanks for your pertinent report.

IMHO, validateResponseFormat() should be perfectly un-opinionated about custom methods and we should harmonize the documentation and types accordingly. Change would not introduce breaking changes as it lower data requirements.

Feedback on this topic will be very gladly welcomed!

@fzaninotto
Copy link
Member

I agree, validateResponseFormat should only be called on the dataProvider methods documented there:

https://marmelab.com/react-admin/DataProviderWriting.html#request-format

I'm marking this as an enhancement. Feel free to open a PR to implement it.

@ogustavo-pereira
Copy link
Contributor

I can try to help with this update

@fzaninotto
Copy link
Member

Sure, please do!

@fzaninotto
Copy link
Member

Fixed by #8159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants