Skip to content

Commit 50b1097

Browse files
authored
fix(workaround): multipart subscriptions that terminate with payload: null (#11594)
* fix(workaround): multipart subscriptions that terminate with payload: null * Clean up Prettier, Size-limit, and Api-Extractor
1 parent 9e74ade commit 50b1097

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

.changeset/little-squids-watch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@apollo/client": patch
3+
---
4+
5+
Adds a fix for multipart subscriptions that terminate with payload: null

.size-limits.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"dist/apollo-client.min.cjs": 39229,
3-
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32616
2+
"dist/apollo-client.min.cjs": 39245,
3+
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32630
44
}

src/link/http/__tests__/HttpLink.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,10 @@ describe("HttpLink", () => {
19401940
"Content-Type: application/json",
19411941
"",
19421942
'{"payload":{"data":{"aNewDieWasCreated":{"die":{"color":"blue","roll":2,"sides":5}}}}}',
1943+
"---",
1944+
"Content-Type: application/json",
1945+
"",
1946+
'{"payload": null}',
19431947
"-----",
19441948
].join("\r\n");
19451949

src/link/http/parseAndCheckHttpResponse.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ export async function readMultipartBody<
8484
if (isApolloPayloadResult(result)) {
8585
let next = {};
8686
if ("payload" in result) {
87+
if (Object.keys(result).length === 1 && result.payload === null) {
88+
return;
89+
}
8790
next = { ...result.payload };
8891
}
8992
if ("errors" in result) {

0 commit comments

Comments
 (0)