-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
📝 Document SSR & persistence/rehydration related features #1639
📝 Document SSR & persistence/rehydration related features #1639
Conversation
Let's target this to point at the SSR PR so we can see exactly what's in this, and we can retarget against the 1.7 branch after the SSR PR is merged. |
```ts no-transpile | ||
const getRunningOperationPromise: <EndpointName extends QueryKeys<Definitions>>( | ||
endpointName: EndpointName, | ||
args: QueryArgFrom<Definitions[EndpointName]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args
can also be fixedCacheKey
or requestId
in the case of a mutation.
Maybe we should write three signatures here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated this signature as per #1277 (comment), but note that it hasn't been applied to #1277 at this stage
Nice work on this! I'm not very read up on the current state of #1277 so I can't really have any feedback on correctness or missing pieces, but reading this somewhat from an outside perspective I found the docs clear. 😄 One thing I'm curious about that didn't come up, and I'm not sure if it's been discussed, is how to refetch the data on the client after the initial render? With SSG especially, but also SSR with long cache times, the data can be very stale compared to when working inside a single session so to speak, what is the recommended way to revalidate in those cases? Is it/can it be automatic and if not, do you have access to how old a query is etc so you can do it manually? (Note that I'm not a heavy user of RTK Query, maybe this is already covered in other parts of the docs?) |
@Ephem good goint! Especially in a SSG scenario one would probably want to set |
92149e1
to
f17724e
Compare
:::tip | ||
In order to avoid providing stale data with Static Site Generation (SSG), you may wish to set | ||
[`refetchOnMountOrArgChange`](../api/createApi.mdx#refetchonmountorargchange) to a reasonable value | ||
such as 900 (seconds) in order to allow data to be re-fetched when accessed if it has been that | ||
long since the page was generated. | ||
::: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ephem @phryneas FYI I've added this note to account for stale SSG data as per #1639 (comment) & #1639 (comment)
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a04208e:
|
I've moved the new functions from |
- Merge 'Cache Management Utils' & 'Miscellaneous Utils' into 'API Slice Utils' - Add re-direct from `cache-management-utils` to `api-slice-utils`
45499cc
to
55560b2
Compare
I've updated it to account for this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add some minor changes on top and merge this. Thanks a ton, your help really means a lot 😊
Note: This is reliant on #1277
This mainly adds stubs extracted from #1277 (comment)
Cache Management Utils
is changed toAPI Slice Utils
. A re-direct has been added to accomodate this.