You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can set this globally in `createApi`, but you can also override the default value and have more granular control by passing `onSchemaFailure` to each individual endpoint definition.
You can set this globally in `createApi`, but you can also override the default value and have more granular control by passing `skipSchemaValidation` to each individual endpoint definition.
* A function that is called when a schema validation fails.
219
+
*
220
+
* Gets called with a `NamedSchemaError` and an object containing the endpoint name, the type of the endpoint, the argument passed to the endpoint, and the query cache key (if applicable).
221
+
*
222
+
* `NamedSchemaError` has the following properties:
223
+
* - `issues`: an array of issues that caused the validation to fail
224
+
* - `value`: the value that was passed to the schema
225
+
* - `schemaName`: the name of the schema that was used to validate the value (e.g. `argSchema`)
226
+
*
227
+
* @example
228
+
* ```ts
229
+
* // codeblock-meta no-transpile
230
+
* import { createApi } from '@reduxjs/toolkit/query/react'
231
+
* import * as v from "valibot"
232
+
*
233
+
* const api = createApi({
234
+
* baseQuery: fetchBaseQuery({ baseUrl: '/' }),
235
+
* endpoints: (build) => ({
236
+
* getPost: build.query<Post, { id: number }>({
237
+
* query: ({ id }) => `/post/${id}`,
238
+
* }),
239
+
* }),
240
+
* onSchemaFailure: (error, info) => {
241
+
* console.error(error, info)
242
+
* },
243
+
* })
244
+
* ```
245
+
*/
217
246
onSchemaFailure?: SchemaFailureHandler
247
+
/**
248
+
* Defaults to `false`.
249
+
*
250
+
* If set to `true`, will skip schema validation for all endpoints, unless overridden by the endpoint.
251
+
*
252
+
* @example
253
+
* ```ts
254
+
* // codeblock-meta no-transpile
255
+
* import { createApi } from '@reduxjs/toolkit/query/react'
256
+
* import * as v from "valibot"
257
+
*
258
+
* const api = createApi({
259
+
* baseQuery: fetchBaseQuery({ baseUrl: '/' }),
260
+
* skipSchemaValidation: process.env.NODE_ENV === "test", // skip schema validation in tests, since we'll be mocking the response
* A function that is called when a schema validation fails.
355
+
*
356
+
* Gets called with a `NamedSchemaError` and an object containing the endpoint name, the type of the endpoint, the argument passed to the endpoint, and the query cache key (if applicable).
357
+
*
358
+
* `NamedSchemaError` has the following properties:
359
+
* - `issues`: an array of issues that caused the validation to fail
360
+
* - `value`: the value that was passed to the schema
361
+
* - `schemaName`: the name of the schema that was used to validate the value (e.g. `argSchema`)
362
+
*
363
+
* @example
364
+
* ```ts
365
+
* // codeblock-meta no-transpile
366
+
* import { createApi } from '@reduxjs/toolkit/query/react'
367
+
* import * as v from "valibot"
368
+
*
369
+
* const api = createApi({
370
+
* baseQuery: fetchBaseQuery({ baseUrl: '/' }),
371
+
* endpoints: (build) => ({
372
+
* getPost: build.query<Post, { id: number }>({
373
+
* query: ({ id }) => `/post/${id}`,
374
+
* onSchemaFailure: (error, info) => {
375
+
* console.error(error, info)
376
+
* },
377
+
* }),
378
+
* })
379
+
* })
380
+
* ```
381
+
*/
359
382
onSchemaFailure?: SchemaFailureHandler
383
+
384
+
/**
385
+
* Defaults to `false`.
386
+
*
387
+
* If set to `true`, will skip schema validation for this endpoint.
388
+
* Overrides the global setting.
389
+
*
390
+
* @example
391
+
* ```ts
392
+
* // codeblock-meta no-transpile
393
+
* import { createApi } from '@reduxjs/toolkit/query/react'
0 commit comments