Closed markerikson closed 3 years ago
In regards the last question, I think the level of separation from the rest of the docs will be dependent on how it is integrated into the larger RTK library.
At the moment, the rough plan is that the createApi
function currently in this "RTK Query" package will be just another API exported from RTK directly, like configureStore
and createSlice
. So, the intent is that there's one single @reduxjs/toolkit
package, and you get everything at once - it's just a question of which APIs you import and use in your app.
There will be a new "@reduxjs/toolkit/react"
entry point of some kind, which will specifically have the functionality that handles generating React hooks from the API endpoint definitions. (I'm actually still not entirely sure how that logic is organized in this package right now.)
As far as docs organization, I assume there'll be two aspects:
createApi
API reference page, in the same overall section as https://redux-toolkit.js.org/api/createSlice , but possibly nested under a different subcategory like "Data Fetching" instead of "Reducers and Actions"Makes sense, for the second point I'd lean toward putting it as its own category within "Using Redux Toolkit," instead of its own top-level category, as it'll be a decent sized chunk of docs but still comparable to the length of other content in that category. And it wouldn't make as much sense to have it separated because you would be recreating an API Reference section and a Using Redux Toolkit section within the new top level section.
From twitter:
Jakob Heuser @jakobo · 1m Tweet sized fast feedback:
- Less animated checks
- “invalidates: ['Posts']” isn’t hyped up enough. Cache invalidation is a PITA & having a “good enough” pattern is Hundred points symbol
- I’d prefer the feature list be in terms of benefits, as some of the terms like “lagged queries” are jargon
@gfortaine Just wanted to give you a quick ping as you've contributed quite a few things - if you have any additional feedback, please let us know! We have a few more features pending right now that we're aiming to roll out soon. If we're missing anything you've come across, let us know!
@kahirokunn Your input would also be valuable here, thanks!
What final tweaks to the APIs and functionality are needed to consider this "done" and ready for initial stable release?
I can think of three things that would be useful, but I don't think absolutely necessary; in my experience, pagination is frequently done using a skip token rather than just incrementing the page number. I think overall just having another explicit example of changing a query based on the response of a previous query to the same endpoint. I could see pagination using a skip token as an example, or having the polling time set by the retry-after header.
I think overall documentation could be easier to have some more explicit walkthroughs - though perhaps some of that could be done through an updated example to use rtk-query for RTK core's examples.
How should the "RTK Query" docs content be structured inside of the RTK docs? Should there be some kind of an "RTK Query" category, just put this content under "Usage Guides", or something else?
I think it should be its own header, but can also see it being fine as a subheader under "Using Redux Toolkit" as mentioned above.
I feel like the rest of RTK can be seen as a more clean drop-in substitute for Redux for new projects, where rtk-query is more of an additional feature that RTK has that is wonderful integration, but not a default thing that people would think of (the way createSlice/Action/Reducer are). You could maybe make the argument that it should go alongside createAsyncThunk, but even then the use case is related but not really a drop-in.
I think with the amount of documentation and examples you have already on the rtk-query documentation site, it makes the most sense to keep it as a separate header.
Adding some notes from our call:
examples
folder added specifically for RTKQ examples.
listeners
PR and consider packaging an implementation under @rtk-incubatorauthSlice
could be a great place for thisadding from memory:
@msutkowski It looks like that we don't have any additional comments on our side 😀 For your kind reference, we have successfully moved from a homemade fetcher to RTK query like a breeze in our production project. Now, we are eagerly waiting for the 0.3.0 to move forward 👍 Thank you for the great work guys 🎉 @phryneas @msutkowski
So, another TODO would be a rename for:
entity -> tag entityTypes -> tagTypes provides -> providesTags invalidates -> invalidatesTags
Also prefetchThunk
-> prefetch
So, stuff that happened since the last release:
queryFn
as alternative to query
to endpoint definitions (#158) @phryneas
fakeBaseQuery
for apis without any baseQuery
utils.invalidateTags
(#190) @msutkowski
dispatch
. This could be useful for invalidating parts of the cache based on various actions
that pass through middleware.utils.resetApiState
(#189) @msutkowski
api
state in any place that you have access to dispatch
. In addition, this will clean up any existing polling intervals that run in the api middleware.useQuery
for the cases where you don't immediately want to make a request for data. selectFromResult
for mutations ( #206 ) @msutkowski
isLoading
or data
when you do not care about the result. (ex: const [update] = useUpdateUser(1, { selectFromResult: () => ({}) })
) /react
entrypoint @phryneas providesTags/invalidatesTags
when a query has an isError state (#201) @phryneas
this changes the signature of providesTags
and invalidatesTags
from (result, arg) => Tags
to (result?, error?, arg) => Tags
, which allows to provide & invalidate tags even in erroring queriesundefined
, which does not stringify (important for Next.js getServerSideProps) uninitialized
status (#197) @phryneas
useQuery
hooks will now be isLoading
on first render instead of isUninitialized
(except for skipped queries), to simplify the logic the library users have to writeselectFromResult
(#216) @markerikson And of course Docs docs docs by @Shrugsy, @markerikson but also quite a lot of smaller tweaks in master and next. I'm not gonna name all of them here now to avoid a mass ping though.
The primary RTKQ migration work is now done, and I've just published https://github.com/reduxjs/redux-toolkit/releases/tag/v1.6.0-alpha.1 containing the RTKQ APIs as part of the RTK package!
This is basically rtkq@0.3
, but moved over to be under @reduxjs/toolkit/query
and @reduxjs/toolkit/query/react
.
I'm closing everything here now. If there's any need for further discussion, that should take place in a new issue over at https://github.com/reduxjs/redux-toolkit/
The maintainers (@phryneas , @msutkowski , and myself) are hoping to nail down plans within the next few days for finalizing and releasing the "RTK Query" APIs officially.
This will presumably involve migrating the source code for
createApi
over into the Redux Toolkit codebase itself, and moving the documentation from https://rtk-query-docs.netlify.app into the actual Redux Toolkit docs at https://redux-toolkit.js.org . This would be followed by releasing a new Redux Toolkit version with that functionality, likely a v1.6 release.Key things for us to figure out: