Commit 1d6dbe6
authored
fix(client): respect user-provided mapSubresponse in BatchLinkPlugin (#1848)
A custom `mapSubresponse` passed to `BatchLinkPlugin` was silently
ignored: the constructor assigned the built-in implementation
unconditionally instead of using the `options.mapSubresponse ?? ...`
fallback that every other option uses. Users who supplied the hook to
rewrite sub-responses got the default header merge instead, with no
error or warning.
## Fixes
A user-provided `mapSubresponse` now runs for every sub-request, and the
response it returns (headers and body alike) is what reaches the caller.
Behavior is unchanged when the option is omitted.
## Testing
New test in `packages/client/src/plugins/batch.test.ts` supplies a
custom `mapSubresponse` that tags headers and rewrites the body, then
asserts it is called once per sub-request, that its headers reach the
codec, and that its body is what `link.call` resolves to. The batch
response carries its own header so the test also confirms the default
merge is replaced rather than layered on. The test fails on the
unpatched plugin and passes with the fix.1 parent bc0f743 commit 1d6dbe6
2 files changed
Lines changed: 45 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
411 | 454 | | |
412 | 455 | | |
413 | 456 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
0 commit comments