13. Cache & Invalidation
SDK writes already refresh the UI. create, update, and delete invalidate the entity query cache on success, so tables and details pages refetch without any extra call.
The old helper context.mutate(slug) does not exist.
When you do need to invalidate by hand
- A backend process changed data and the UI has not noticed
- You wrote through something other than
context.sdk.entities.* - You need to refresh a different entity than the one you just wrote
await context.sdk.invalidate.entities.getBySlug({ entitySlug: "invoices" });
await context.sdk.invalidate.entities.getById({
entitySlug: "invoices",
recordId: context.router.id
});
await context.sdk.invalidate.entities.all();Prop
Type
context.queryClient
The underlying TanStack Query client is on context.queryClient. Prefer context.sdk.invalidate.* — those keys match what the SDK actually stored.
If you do call invalidateQueries yourself, the list key is:
await context.queryClient.invalidateQueries({
queryKey: ["sdk", "entities"]
});Do not invent keys such as ["invoices"] — they will not match anything the SDK cached.