marmelab / marmelab/react-admin
make DataProvider an interface
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 26.9k
- Forks
- 5.5k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 19
Description
**Is your feature request related to a problem? Please describe.**
Currently, to extend the DataProvider, we have to be very explicit about generics, and do a fair amount of hackery to expose Models/Resources everywhere.
The aim here is to build an abstraction around the pieces in react-admin, to make wiring up APIs/Models/Views a lot more seamless within editor environments (fully static with plain JS for users).
**Describe the solution you'd like**
Currently, `DataProvider` is a TypeAlias, which are not injectable.
By allowing us to inject the `DataProvider`, we can cause `resourceName -> RaRecord` associations to propagate to all the hooks (`useGetList('cats')` should automatically find my Cat Model).
For now, changing it from `type` to `interface` might be enough, however I'm unsure of the fallout. I'll spin up a PR with a Demo to verify how it all goes, and so you have something physical to see.
I suspect this will be beneficial for the `no-code` project, however I've yet to do a dive into what that is in detail.
**Describe alternatives you've considered**
Wrapping + explicit types == Code too noisy
**Additional context**
n/a
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the DataProvider type alias and inspect its usages in the hooks and resource/model typings. Check how changing it to an interface affects generic propagation and injectable typing, then validate the behavior with the proposed demo; done means the resourceName-to-RaRecord association works across hooks without explicit generic wrappers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100