build(deps): bump @reduxjs/toolkit from 1.9.7 to 2.7.0
Bumps @reduxjs/toolkit from 1.9.7 to 2.7.0.
Release notes
Sourced from @reduxjs/toolkit's releases.
v2.7.0
RTK has hit Stage 2.7! :rofl: This feature release adds support for Standard Schema validation in RTK Query endpoints, fixes several issues with infinite queries, improves perf when infinite queries provide tags, adds a dev-mode check for duplicate middleware, and improves reference stability in slice selectors and infinite query hooks.
Changelog
Standard Schema Validation for RTK Query
Apps often need to validate responses from the server, both to ensure the data is correct, and to help enforce that the data matches the expected TS types. This is typically done with schema libraries such as Zod, Valibot, and Arktype. Because of the similarities in usage APIs, those libraries and others now support a common API definition called Standard Schema, allowing you to plug your chosen validation library in anywhere Standard Schema is supported.
RTK Query now supports using Standard Schema to validate query args, responses, and errors. If schemas are provided, the validations will be run and errors thrown if the data is invalid. Additionally, providing a schema allows TS inference for that type as well, allowing you to omit generic types from the endpoint.
Schema usage is per-endpoint, and can look like this:
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react' import * as v from 'valibot'const postSchema = v.object({
id: v.number(),
name: v.string(),
})
type Post = v.InferOutput<typeof postSchema>const api = createApi({
baseQuery: fetchBaseQuery({ baseUrl: '/' }),
endpoints: (build) => ({
getPost: build.query({
// infer arg from here
query: ({ id }: { id: number }) =>/post/${id},
// infer result from here
responseSchema: postSchema,
}),
getTransformedPost: build.query({
// infer arg from here
query: ({ id }: { id: number }) =>/post/${id},
// infer untransformed result from here
rawResponseSchema: postSchema,
// infer transformed result from here
transformResponse: (response) => ({
...response,
published_at: new Date(response.published_at),
}),
}),
}),
})
If desired, you can also configure schema error handling with the
catchSchemaFailureoption. You can also disable actual runtime validation withskipSchemaValidation(primarily useful for cases when payloads may be large and expensive to validate, but you still want to benefit from the TS type inference).See the "Schema Validation" docs section in the
createApireference and the usage guide sections on queries, infinite queries, and mutations, for more details.
... (truncated)
Commits
3592b08Release 2.7.09a8d429AddcatchSchemaFailure, and docs for RTKQ schema features (#4934)ad4696cimprove stability of useInfiniteQuerySubscription's return value (#4937)ad2b288Add meta handling for infinite queries (#4939)78833cbImprove duplicate middleware error and save build output (#4928)e730507Add duplicate middleware dev check to configureStore (#4927)9881b1aDrop TS 5.0 from compat matrix (#4925)c89fce3fix(rtk-query):useQueryhook does not refetch afterresetApiState(#4758)45a95cbAllow standard schemas to validate endpoint values (#4864)9eb51e9Rewrite providedTags handling for better perf (#4910)- Additional commits viewable in compare view
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
-
@dependabot rebasewill rebase this PR -
@dependabot recreatewill recreate this PR, overwriting any edits that have been made to it -
@dependabot mergewill merge this PR after your CI passes on it -
@dependabot squash and mergewill squash and merge this PR after your CI passes on it -
@dependabot cancel mergewill cancel a previously requested merge and block automerging -
@dependabot reopenwill reopen this PR if it is closed -
@dependabot closewill close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually -
@dependabot show <dependency name> ignore conditionswill show all of the ignore conditions of the specified dependency -
@dependabot ignore this major versionwill close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) -
@dependabot ignore this minor versionwill close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) -
@dependabot ignore this dependencywill close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)