@@ -31,6 +31,7 @@ import type {
3131 SchemaFailureConverter ,
3232 SchemaFailureHandler ,
3333 SchemaFailureInfo ,
34+ SchemaType ,
3435} from '../endpointDefinitions'
3536import {
3637 calculateProvidedBy ,
@@ -68,7 +69,11 @@ import {
6869 isRejectedWithValue ,
6970 SHOULD_AUTOBATCH ,
7071} from './rtkImports'
71- import { parseWithSchema , NamedSchemaError } from '../standardSchema'
72+ import {
73+ parseWithSchema ,
74+ NamedSchemaError ,
75+ shouldSkip ,
76+ } from '../standardSchema'
7277
7378export type BuildThunksApiEndpointQuery <
7479 Definition extends QueryDefinition < any , any , any , any , any > ,
@@ -346,7 +351,7 @@ export function buildThunks<
346351 selectors : AllSelectors
347352 onSchemaFailure : SchemaFailureHandler | undefined
348353 catchSchemaFailure : SchemaFailureConverter < BaseQuery > | undefined
349- skipSchemaValidation : boolean | undefined
354+ skipSchemaValidation : boolean | SchemaType [ ] | undefined
350355} ) {
351356 type State = RootState < any , string , ReducerPath >
352357
@@ -569,7 +574,7 @@ export function buildThunks<
569574 const { extraOptions, argSchema, rawResponseSchema, responseSchema } =
570575 endpointDefinition
571576
572- if ( argSchema && ! skipSchemaValidation ) {
577+ if ( argSchema && ! shouldSkip ( skipSchemaValidation , 'arg' ) ) {
573578 finalQueryArg = await parseWithSchema (
574579 argSchema ,
575580 finalQueryArg ,
@@ -633,7 +638,10 @@ export function buildThunks<
633638
634639 let { data } = result
635640
636- if ( rawResponseSchema && ! skipSchemaValidation ) {
641+ if (
642+ rawResponseSchema &&
643+ ! shouldSkip ( skipSchemaValidation , 'rawResponse' )
644+ ) {
637645 data = await parseWithSchema (
638646 rawResponseSchema ,
639647 result . data ,
@@ -648,7 +656,7 @@ export function buildThunks<
648656 finalQueryArg ,
649657 )
650658
651- if ( responseSchema && ! skipSchemaValidation ) {
659+ if ( responseSchema && ! shouldSkip ( skipSchemaValidation , 'response' ) ) {
652660 transformedResponse = await parseWithSchema (
653661 responseSchema ,
654662 transformedResponse ,
@@ -751,7 +759,11 @@ export function buildThunks<
751759 finalQueryReturnValue = await executeRequest ( arg . originalArgs )
752760 }
753761
754- if ( metaSchema && ! skipSchemaValidation && finalQueryReturnValue . meta ) {
762+ if (
763+ metaSchema &&
764+ ! shouldSkip ( skipSchemaValidation , 'meta' ) &&
765+ finalQueryReturnValue . meta
766+ ) {
755767 finalQueryReturnValue . meta = await parseWithSchema (
756768 metaSchema ,
757769 finalQueryReturnValue . meta ,
@@ -781,7 +793,10 @@ export function buildThunks<
781793 let { value, meta } = caughtError
782794
783795 try {
784- if ( rawErrorResponseSchema && ! skipSchemaValidation ) {
796+ if (
797+ rawErrorResponseSchema &&
798+ ! shouldSkip ( skipSchemaValidation , 'rawErrorResponse' )
799+ ) {
785800 value = await parseWithSchema (
786801 rawErrorResponseSchema ,
787802 value ,
@@ -790,15 +805,18 @@ export function buildThunks<
790805 )
791806 }
792807
793- if ( metaSchema && ! skipSchemaValidation ) {
808+ if ( metaSchema && ! shouldSkip ( skipSchemaValidation , 'meta' ) ) {
794809 meta = await parseWithSchema ( metaSchema , meta , 'metaSchema' , meta )
795810 }
796811 let transformedErrorResponse = await transformErrorResponse (
797812 value ,
798813 meta ,
799814 arg . originalArgs ,
800815 )
801- if ( errorResponseSchema && ! skipSchemaValidation ) {
816+ if (
817+ errorResponseSchema &&
818+ ! shouldSkip ( skipSchemaValidation , 'errorResponse' )
819+ ) {
802820 transformedErrorResponse = await parseWithSchema (
803821 errorResponseSchema ,
804822 transformedErrorResponse ,
0 commit comments