@@ -407,7 +407,9 @@ export interface StaticHandler {
407
407
opts ?: {
408
408
loadRouteIds ?: string [ ] ;
409
409
requestContext ?: unknown ;
410
+ skipLoaders ?: boolean ;
410
411
skipLoaderErrorBubbling ?: boolean ;
412
+ unstable_dataStrategy ?: DataStrategyFunction ;
411
413
}
412
414
) : Promise < StaticHandlerContext | Response > ;
413
415
queryRoute (
@@ -2926,7 +2928,6 @@ export interface CreateStaticHandlerOptions {
2926
2928
* @deprecated Use `mapRouteProperties` instead
2927
2929
*/
2928
2930
detectErrorBoundary ?: DetectErrorBoundaryFunction ;
2929
- unstable_dataStrategy ?: DataStrategyFunction ;
2930
2931
mapRouteProperties ?: MapRoutePropertiesFunction ;
2931
2932
future ?: Partial < StaticHandlerFutureConfig > ;
2932
2933
}
@@ -2942,7 +2943,6 @@ export function createStaticHandler(
2942
2943
2943
2944
let manifest : RouteManifest = { } ;
2944
2945
let basename = ( opts ? opts . basename : null ) || "/" ;
2945
- let dataStrategyImpl = opts ?. unstable_dataStrategy || defaultDataStrategy ;
2946
2946
let mapRouteProperties : MapRoutePropertiesFunction ;
2947
2947
if ( opts ?. mapRouteProperties ) {
2948
2948
mapRouteProperties = opts . mapRouteProperties ;
@@ -2988,25 +2988,31 @@ export function createStaticHandler(
2988
2988
* propagate that out and return the raw Response so the HTTP server can
2989
2989
* return it directly.
2990
2990
*
2991
- * - `opts.loadRouteIds` is an optional array of routeIds if you wish to only
2992
- * run a subset of route loaders on a GET request
2991
+ * - `opts.loadRouteIds` is an optional array of routeIds to run only a subset of
2992
+ * loaders during a query() call
2993
2993
* - `opts.requestContext` is an optional server context that will be passed
2994
2994
* to actions/loaders in the `context` parameter
2995
2995
* - `opts.skipLoaderErrorBubbling` is an optional parameter that will prevent
2996
- * the bubbling of loader errors which allows single-fetch-type implementations
2996
+ * the bubbling of errors which allows single-fetch-type implementations
2997
2997
* where the client will handle the bubbling and we may need to return data
2998
2998
* for the handling route
2999
+ * - `opts.skipLoaders` is an optional parameter that will prevent loaders
3000
+ * from running after an action
2999
3001
*/
3000
3002
async function query (
3001
3003
request : Request ,
3002
3004
{
3003
3005
loadRouteIds,
3004
3006
requestContext,
3005
3007
skipLoaderErrorBubbling,
3008
+ skipLoaders,
3009
+ unstable_dataStrategy,
3006
3010
} : {
3007
3011
loadRouteIds ?: string [ ] ;
3008
3012
requestContext ?: unknown ;
3009
3013
skipLoaderErrorBubbling ?: boolean ;
3014
+ skipLoaders ?: boolean ;
3015
+ unstable_dataStrategy ?: DataStrategyFunction ;
3010
3016
} = { }
3011
3017
) : Promise < StaticHandlerContext | Response > {
3012
3018
let url = new URL ( request . url ) ;
@@ -3058,8 +3064,10 @@ export function createStaticHandler(
3058
3064
location ,
3059
3065
matches ,
3060
3066
requestContext ,
3067
+ unstable_dataStrategy || null ,
3061
3068
loadRouteIds || null ,
3062
3069
skipLoaderErrorBubbling === true ,
3070
+ skipLoaders === true ,
3063
3071
null
3064
3072
) ;
3065
3073
if ( isResponse ( result ) ) {
@@ -3137,6 +3145,8 @@ export function createStaticHandler(
3137
3145
matches ,
3138
3146
requestContext ,
3139
3147
null ,
3148
+ null ,
3149
+ false ,
3140
3150
false ,
3141
3151
match
3142
3152
) ;
@@ -3174,8 +3184,10 @@ export function createStaticHandler(
3174
3184
location : Location ,
3175
3185
matches : AgnosticDataRouteMatch [ ] ,
3176
3186
requestContext : unknown ,
3187
+ unstable_dataStrategy : DataStrategyFunction | null ,
3177
3188
loadRouteIds : string [ ] | null ,
3178
3189
skipLoaderErrorBubbling : boolean ,
3190
+ skipLoaders : boolean ,
3179
3191
routeMatch : AgnosticDataRouteMatch | null
3180
3192
) : Promise < Omit < StaticHandlerContext , "location" | "basename" > | Response > {
3181
3193
invariant (
@@ -3190,8 +3202,10 @@ export function createStaticHandler(
3190
3202
matches ,
3191
3203
routeMatch || getTargetMatch ( matches , location ) ,
3192
3204
requestContext ,
3205
+ unstable_dataStrategy ,
3193
3206
loadRouteIds ,
3194
3207
skipLoaderErrorBubbling ,
3208
+ skipLoaders ,
3195
3209
routeMatch != null
3196
3210
) ;
3197
3211
return result ;
@@ -3201,6 +3215,7 @@ export function createStaticHandler(
3201
3215
request ,
3202
3216
matches ,
3203
3217
requestContext ,
3218
+ unstable_dataStrategy ,
3204
3219
loadRouteIds ,
3205
3220
skipLoaderErrorBubbling ,
3206
3221
routeMatch
@@ -3236,8 +3251,10 @@ export function createStaticHandler(
3236
3251
matches : AgnosticDataRouteMatch [ ] ,
3237
3252
actionMatch : AgnosticDataRouteMatch ,
3238
3253
requestContext : unknown ,
3254
+ unstable_dataStrategy : DataStrategyFunction | null ,
3239
3255
loadRouteIds : string [ ] | null ,
3240
3256
skipLoaderErrorBubbling : boolean ,
3257
+ skipLoaders : boolean ,
3241
3258
isRouteRequest : boolean
3242
3259
) : Promise < Omit < StaticHandlerContext , "location" | "basename" > | Response > {
3243
3260
let result : DataResult ;
@@ -3262,7 +3279,8 @@ export function createStaticHandler(
3262
3279
[ actionMatch ] ,
3263
3280
matches ,
3264
3281
isRouteRequest ,
3265
- requestContext
3282
+ requestContext ,
3283
+ unstable_dataStrategy
3266
3284
) ;
3267
3285
result = results [ 0 ] ;
3268
3286
@@ -3326,11 +3344,38 @@ export function createStaticHandler(
3326
3344
if ( isErrorResult ( result ) ) {
3327
3345
// Store off the pending error - we use it to determine which loaders
3328
3346
// to call and will commit it when we complete the navigation
3329
- let boundaryMatch = findNearestBoundary ( matches , actionMatch . route . id ) ;
3347
+ let boundaryMatch = skipLoaderErrorBubbling
3348
+ ? actionMatch
3349
+ : findNearestBoundary ( matches , actionMatch . route . id ) ;
3350
+ let statusCode = isRouteErrorResponse ( result . error )
3351
+ ? result . error . status
3352
+ : result . statusCode != null
3353
+ ? result . statusCode
3354
+ : 500 ;
3355
+ let actionHeaders = {
3356
+ ...( result . headers ? { [ actionMatch . route . id ] : result . headers } : { } ) ,
3357
+ } ;
3358
+
3359
+ if ( skipLoaders ) {
3360
+ return {
3361
+ matches,
3362
+ loaderData : { } ,
3363
+ actionData : { } ,
3364
+ errors : {
3365
+ [ boundaryMatch . route . id ] : result . error ,
3366
+ } ,
3367
+ statusCode,
3368
+ loaderHeaders : { } ,
3369
+ actionHeaders,
3370
+ activeDeferreds : null ,
3371
+ } ;
3372
+ }
3373
+
3330
3374
let context = await loadRouteData (
3331
3375
loaderRequest ,
3332
3376
matches ,
3333
3377
requestContext ,
3378
+ unstable_dataStrategy ,
3334
3379
loadRouteIds ,
3335
3380
skipLoaderErrorBubbling ,
3336
3381
null ,
@@ -3340,20 +3385,36 @@ export function createStaticHandler(
3340
3385
// action status codes take precedence over loader status codes
3341
3386
return {
3342
3387
...context ,
3343
- statusCode : isRouteErrorResponse ( result . error )
3344
- ? result . error . status
3345
- : 500 ,
3388
+ statusCode,
3346
3389
actionData : null ,
3347
- actionHeaders : {
3348
- ...( result . headers ? { [ actionMatch . route . id ] : result . headers } : { } ) ,
3390
+ actionHeaders,
3391
+ } ;
3392
+ }
3393
+
3394
+ let actionHeaders = result . headers
3395
+ ? { [ actionMatch . route . id ] : result . headers }
3396
+ : { } ;
3397
+
3398
+ if ( skipLoaders ) {
3399
+ return {
3400
+ matches,
3401
+ loaderData : { } ,
3402
+ actionData : {
3403
+ [ actionMatch . route . id ] : result . data ,
3349
3404
} ,
3405
+ errors : null ,
3406
+ statusCode : result . statusCode || 200 ,
3407
+ loaderHeaders : { } ,
3408
+ actionHeaders,
3409
+ activeDeferreds : null ,
3350
3410
} ;
3351
3411
}
3352
3412
3353
3413
let context = await loadRouteData (
3354
3414
loaderRequest ,
3355
3415
matches ,
3356
3416
requestContext ,
3417
+ unstable_dataStrategy ,
3357
3418
loadRouteIds ,
3358
3419
skipLoaderErrorBubbling ,
3359
3420
null
@@ -3376,6 +3437,7 @@ export function createStaticHandler(
3376
3437
request : Request ,
3377
3438
matches : AgnosticDataRouteMatch [ ] ,
3378
3439
requestContext : unknown ,
3440
+ unstable_dataStrategy : DataStrategyFunction | null ,
3379
3441
loadRouteIds : string [ ] | null ,
3380
3442
skipLoaderErrorBubbling : boolean ,
3381
3443
routeMatch : AgnosticDataRouteMatch | null ,
@@ -3444,7 +3506,8 @@ export function createStaticHandler(
3444
3506
matchesToLoad ,
3445
3507
matches ,
3446
3508
isRouteRequest ,
3447
- requestContext
3509
+ requestContext ,
3510
+ unstable_dataStrategy
3448
3511
) ;
3449
3512
3450
3513
if ( request . signal . aborted ) {
@@ -3490,10 +3553,11 @@ export function createStaticHandler(
3490
3553
matchesToLoad : AgnosticDataRouteMatch [ ] ,
3491
3554
matches : AgnosticDataRouteMatch [ ] ,
3492
3555
isRouteRequest : boolean ,
3493
- requestContext : unknown
3556
+ requestContext : unknown ,
3557
+ unstable_dataStrategy : DataStrategyFunction | null
3494
3558
) : Promise < DataResult [ ] > {
3495
3559
let results = await callDataStrategyImpl (
3496
- dataStrategyImpl ,
3560
+ unstable_dataStrategy || defaultDataStrategy ,
3497
3561
type ,
3498
3562
request ,
3499
3563
matchesToLoad ,
@@ -4188,6 +4252,7 @@ async function callDataStrategyImpl(
4188
4252
} ) ,
4189
4253
request,
4190
4254
params : matches [ 0 ] . params ,
4255
+ context : requestContext ,
4191
4256
} ) ;
4192
4257
4193
4258
// Throw if any loadRoute implementations not called since they are what
0 commit comments