Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Allow specifying queryFn in endpoint definitions to skip baseQuery? #139

Closed
phryneas opened this issue Jan 1, 2021 · 1 comment · Fixed by #158
Closed

Allow specifying queryFn in endpoint definitions to skip baseQuery? #139

phryneas opened this issue Jan 1, 2021 · 1 comment · Fixed by #158
Labels
discussion Requires further discussion
Milestone

Comments

@phryneas
Copy link
Collaborator

phryneas commented Jan 1, 2021

Inspired by https://www.reddit.com/r/reactjs/comments/kkq8bi/alpha_2_of_rtkquery_released/ghovnvh/?context=3

This would allow endpoints to get a queryFn option that would replace & skip the baseQuery for that endpoint. query would become optional in that case and default to x => x.

That way, stuff like the google api client, or maybe firebase, could just be used as asynchronous functions.

From the codebase and our internal workflows it should be feasible to implement without too many changes.

Any thoughts?

@utkarshgupta137
Copy link

utkarshgupta137 commented Jan 1, 2021

To add this, I have some like this. Here, fetchPlaylistItems is calling fetchVideos with its result, which then makes another call, after which the state is updated.

As far as I can tell, there is no straightforward way to do this with the current flow. Having the option to use our own functions will make it much easier to do this.

Also, IMO, the library should be agnostic to the fetching part in-general, and the current baseQuery/query should be like an opinionated way of doing things (or like a wrapper for doing away with repetitive code) as a separate createOpinionatedApi. This will also remove the need for selectFromResult. I guess I'm asking for a more react-query like behaviour.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
discussion Requires further discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants