@@ -333,6 +333,7 @@ export function buildThunks<
333
333
assertTagType,
334
334
selectors,
335
335
onSchemaFailure,
336
+ skipSchemaValidation : globalSkipSchemaValidation ,
336
337
} : {
337
338
baseQuery : BaseQuery
338
339
reducerPath : ReducerPath
@@ -342,6 +343,7 @@ export function buildThunks<
342
343
assertTagType : AssertTagTypes
343
344
selectors : AllSelectors
344
345
onSchemaFailure : SchemaFailureHandler | undefined
346
+ skipSchemaValidation : boolean | undefined
345
347
} ) {
346
348
type State = RootState < any , string , ReducerPath >
347
349
@@ -496,7 +498,8 @@ export function buildThunks<
496
498
} ,
497
499
) => {
498
500
const endpointDefinition = endpointDefinitions [ arg . endpointName ]
499
- const { metaSchema } = endpointDefinition
501
+ const { metaSchema, skipSchemaValidation = globalSkipSchemaValidation } =
502
+ endpointDefinition
500
503
501
504
try {
502
505
let transformResponse = getTransformCallbackForEndpoint (
@@ -562,7 +565,7 @@ export function buildThunks<
562
565
const { extraOptions, argSchema, rawResponseSchema, responseSchema } =
563
566
endpointDefinition
564
567
565
- if ( argSchema ) {
568
+ if ( argSchema && ! skipSchemaValidation ) {
566
569
finalQueryArg = await parseWithSchema (
567
570
argSchema ,
568
571
finalQueryArg ,
@@ -625,7 +628,7 @@ export function buildThunks<
625
628
626
629
let { data } = result
627
630
628
- if ( rawResponseSchema ) {
631
+ if ( rawResponseSchema && ! skipSchemaValidation ) {
629
632
data = await parseWithSchema (
630
633
rawResponseSchema ,
631
634
result . data ,
@@ -639,7 +642,7 @@ export function buildThunks<
639
642
finalQueryArg ,
640
643
)
641
644
642
- if ( responseSchema ) {
645
+ if ( responseSchema && ! skipSchemaValidation ) {
643
646
transformedResponse = await parseWithSchema (
644
647
responseSchema ,
645
648
transformedResponse ,
@@ -736,7 +739,7 @@ export function buildThunks<
736
739
finalQueryReturnValue = await executeRequest ( arg . originalArgs )
737
740
}
738
741
739
- if ( metaSchema && finalQueryReturnValue . meta ) {
742
+ if ( metaSchema && ! skipSchemaValidation && finalQueryReturnValue . meta ) {
740
743
finalQueryReturnValue . meta = await parseWithSchema (
741
744
metaSchema ,
742
745
finalQueryReturnValue . meta ,
@@ -765,15 +768,15 @@ export function buildThunks<
765
768
766
769
let { value, meta } = caughtError
767
770
768
- if ( rawErrorResponseSchema ) {
771
+ if ( rawErrorResponseSchema && ! skipSchemaValidation ) {
769
772
value = await parseWithSchema (
770
773
rawErrorResponseSchema ,
771
774
value ,
772
775
'rawErrorResponseSchema' ,
773
776
)
774
777
}
775
778
776
- if ( metaSchema ) {
779
+ if ( metaSchema && ! skipSchemaValidation ) {
777
780
meta = await parseWithSchema ( metaSchema , meta , 'metaSchema' )
778
781
}
779
782
@@ -783,7 +786,7 @@ export function buildThunks<
783
786
meta ,
784
787
arg . originalArgs ,
785
788
)
786
- if ( errorResponseSchema ) {
789
+ if ( errorResponseSchema && ! skipSchemaValidation ) {
787
790
transformedErrorResponse = await parseWithSchema (
788
791
errorResponseSchema ,
789
792
transformedErrorResponse ,
0 commit comments