@@ -342,6 +342,7 @@ export function buildThunks<
342
342
assertTagType,
343
343
selectors,
344
344
onSchemaFailure,
345
+ skipSchemaValidation : globalSkipSchemaValidation ,
345
346
} : {
346
347
baseQuery : BaseQuery
347
348
reducerPath : ReducerPath
@@ -351,6 +352,7 @@ export function buildThunks<
351
352
assertTagType : AssertTagTypes
352
353
selectors : AllSelectors
353
354
onSchemaFailure : SchemaFailureHandler | undefined
355
+ skipSchemaValidation : boolean | undefined
354
356
} ) {
355
357
type State = RootState < any , string , ReducerPath >
356
358
@@ -507,7 +509,8 @@ export function buildThunks<
507
509
} ,
508
510
) => {
509
511
const endpointDefinition = endpointDefinitions [ arg . endpointName ]
510
- const { metaSchema } = endpointDefinition
512
+ const { metaSchema, skipSchemaValidation = globalSkipSchemaValidation } =
513
+ endpointDefinition
511
514
512
515
try {
513
516
let transformResponse = getTransformCallbackForEndpoint (
@@ -573,7 +576,7 @@ export function buildThunks<
573
576
const { extraOptions, argSchema, rawResponseSchema, responseSchema } =
574
577
endpointDefinition
575
578
576
- if ( argSchema ) {
579
+ if ( argSchema && ! skipSchemaValidation ) {
577
580
finalQueryArg = await parseWithSchema (
578
581
argSchema ,
579
582
finalQueryArg ,
@@ -636,7 +639,7 @@ export function buildThunks<
636
639
637
640
let { data } = result
638
641
639
- if ( rawResponseSchema ) {
642
+ if ( rawResponseSchema && ! skipSchemaValidation ) {
640
643
data = await parseWithSchema (
641
644
rawResponseSchema ,
642
645
result . data ,
@@ -650,7 +653,7 @@ export function buildThunks<
650
653
finalQueryArg ,
651
654
)
652
655
653
- if ( responseSchema ) {
656
+ if ( responseSchema && ! skipSchemaValidation ) {
654
657
transformedResponse = await parseWithSchema (
655
658
responseSchema ,
656
659
transformedResponse ,
@@ -747,7 +750,7 @@ export function buildThunks<
747
750
finalQueryReturnValue = await executeRequest ( arg . originalArgs )
748
751
}
749
752
750
- if ( metaSchema && finalQueryReturnValue . meta ) {
753
+ if ( metaSchema && ! skipSchemaValidation && finalQueryReturnValue . meta ) {
751
754
finalQueryReturnValue . meta = await parseWithSchema (
752
755
metaSchema ,
753
756
finalQueryReturnValue . meta ,
@@ -776,15 +779,15 @@ export function buildThunks<
776
779
777
780
let { value, meta } = caughtError
778
781
779
- if ( rawErrorResponseSchema ) {
782
+ if ( rawErrorResponseSchema && ! skipSchemaValidation ) {
780
783
value = await parseWithSchema (
781
784
rawErrorResponseSchema ,
782
785
value ,
783
786
'rawErrorResponseSchema' ,
784
787
)
785
788
}
786
789
787
- if ( metaSchema ) {
790
+ if ( metaSchema && ! skipSchemaValidation ) {
788
791
meta = await parseWithSchema ( metaSchema , meta , 'metaSchema' )
789
792
}
790
793
@@ -794,7 +797,7 @@ export function buildThunks<
794
797
meta ,
795
798
arg . originalArgs ,
796
799
)
797
- if ( errorResponseSchema ) {
800
+ if ( errorResponseSchema && ! skipSchemaValidation ) {
798
801
transformedErrorResponse = await parseWithSchema (
799
802
errorResponseSchema ,
800
803
transformedErrorResponse ,
0 commit comments