@@ -342,6 +342,7 @@ export function buildThunks<
342342 assertTagType,
343343 selectors,
344344 onSchemaFailure,
345+ skipSchemaValidation : globalSkipSchemaValidation ,
345346} : {
346347 baseQuery : BaseQuery
347348 reducerPath : ReducerPath
@@ -351,6 +352,7 @@ export function buildThunks<
351352 assertTagType : AssertTagTypes
352353 selectors : AllSelectors
353354 onSchemaFailure : SchemaFailureHandler | undefined
355+ skipSchemaValidation : boolean | undefined
354356} ) {
355357 type State = RootState < any , string , ReducerPath >
356358
@@ -507,7 +509,8 @@ export function buildThunks<
507509 } ,
508510 ) => {
509511 const endpointDefinition = endpointDefinitions [ arg . endpointName ]
510- const { metaSchema } = endpointDefinition
512+ const { metaSchema, skipSchemaValidation = globalSkipSchemaValidation } =
513+ endpointDefinition
511514
512515 try {
513516 let transformResponse = getTransformCallbackForEndpoint (
@@ -573,7 +576,7 @@ export function buildThunks<
573576 const { extraOptions, argSchema, rawResponseSchema, responseSchema } =
574577 endpointDefinition
575578
576- if ( argSchema ) {
579+ if ( argSchema && ! skipSchemaValidation ) {
577580 finalQueryArg = await parseWithSchema (
578581 argSchema ,
579582 finalQueryArg ,
@@ -636,7 +639,7 @@ export function buildThunks<
636639
637640 let { data } = result
638641
639- if ( rawResponseSchema ) {
642+ if ( rawResponseSchema && ! skipSchemaValidation ) {
640643 data = await parseWithSchema (
641644 rawResponseSchema ,
642645 result . data ,
@@ -650,7 +653,7 @@ export function buildThunks<
650653 finalQueryArg ,
651654 )
652655
653- if ( responseSchema ) {
656+ if ( responseSchema && ! skipSchemaValidation ) {
654657 transformedResponse = await parseWithSchema (
655658 responseSchema ,
656659 transformedResponse ,
@@ -747,7 +750,7 @@ export function buildThunks<
747750 finalQueryReturnValue = await executeRequest ( arg . originalArgs )
748751 }
749752
750- if ( metaSchema && finalQueryReturnValue . meta ) {
753+ if ( metaSchema && ! skipSchemaValidation && finalQueryReturnValue . meta ) {
751754 finalQueryReturnValue . meta = await parseWithSchema (
752755 metaSchema ,
753756 finalQueryReturnValue . meta ,
@@ -776,15 +779,15 @@ export function buildThunks<
776779
777780 let { value, meta } = caughtError
778781
779- if ( rawErrorResponseSchema ) {
782+ if ( rawErrorResponseSchema && ! skipSchemaValidation ) {
780783 value = await parseWithSchema (
781784 rawErrorResponseSchema ,
782785 value ,
783786 'rawErrorResponseSchema' ,
784787 )
785788 }
786789
787- if ( metaSchema ) {
790+ if ( metaSchema && ! skipSchemaValidation ) {
788791 meta = await parseWithSchema ( metaSchema , meta , 'metaSchema' )
789792 }
790793
@@ -794,7 +797,7 @@ export function buildThunks<
794797 meta ,
795798 arg . originalArgs ,
796799 )
797- if ( errorResponseSchema ) {
800+ if ( errorResponseSchema && ! skipSchemaValidation ) {
798801 transformedErrorResponse = await parseWithSchema (
799802 errorResponseSchema ,
800803 transformedErrorResponse ,
0 commit comments