rtk-incubator / rtk-query

Data fetching and caching addon for Redux Toolkit
https://redux-toolkit.js.org/rtk-query/overview
MIT License
626 stars 31 forks source link

No auto-generated hooks when using `fakeBaseQuery` #205

Closed garrettjoecox closed 3 years ago

garrettjoecox commented 3 years ago

Hey there, I'm using the newly added fakeBaseQuery pattern, as we have an already built SDK we are wanting to wrap RTKQ around.

Following the pattern in the fakeBaseQuery tests it doesn't seem the returned value has the auto-generated hooks for the queries added. Is this a design decision, are we stuck with that limitation if we use fakeBaseQuery?

markerikson commented 3 years ago

What build are you using atm? That stuff isn't even released yet, as far as I know.

Note that in the current next branch, we've split up the exports into separate entry points. rtk-query has the UI-agnostic versions of createApi, while rtk-query/react has the React-specific enhanced versions that actually generate the hooks. Assuming you're using one of the CI-built packages, you probably need to use the React-specific entry point instead.

msutkowski commented 3 years ago

What build are you using atm? That stuff isn't even released yet, as far as I know.

Note that in the current next branch, we've split up the exports into separate entry points. rtk-query has the UI-agnostic versions of createApi, while rtk-query/react has the React-specific enhanced versions that actually generate the hooks. Assuming you're using one of the CI-built packages, you probably need to use the React-specific entry point instead.

@garrettjoecox This is correct. You'll need to import from the react entrypoint :tada:

More specifically:

import { createApi } from '@rtk-incubator/rtk-query/react';
import { fakeBaseQuery } from '@rtk-incubator/rtk-query';
garrettjoecox commented 3 years ago

Terrific, this solved my issue.

What build are you using atm?

Using the next branch, the only way we'll be able to use RTKQ is with these changes so looking forward to them getting released 😄

msutkowski commented 3 years ago

@garrettjoecox That's awesome! Keep us posted on your experience. We're almost ready to go - just updating the docs and potentially one more small feature will get merged in today.