Skip to content

Commit

Permalink
fix(workaround): multipart subscriptions that terminate with payload:…
Browse files Browse the repository at this point in the history
… null (#11594)

* fix(workaround): multipart subscriptions that terminate with payload: null

* Clean up Prettier, Size-limit, and Api-Extractor
  • Loading branch information
alessbell committed Mar 8, 2024
1 parent 9e74ade commit 50b1097
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-squids-watch.md
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

Adds a fix for multipart subscriptions that terminate with payload: null
4 changes: 2 additions & 2 deletions .size-limits.json
@@ -1,4 +1,4 @@
{
"dist/apollo-client.min.cjs": 39229,
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32616
"dist/apollo-client.min.cjs": 39245,
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32630
}
4 changes: 4 additions & 0 deletions src/link/http/__tests__/HttpLink.ts
Expand Up @@ -1940,6 +1940,10 @@ describe("HttpLink", () => {
"Content-Type: application/json",
"",
'{"payload":{"data":{"aNewDieWasCreated":{"die":{"color":"blue","roll":2,"sides":5}}}}}',
"---",
"Content-Type: application/json",
"",
'{"payload": null}',
"-----",
].join("\r\n");

Expand Down
3 changes: 3 additions & 0 deletions src/link/http/parseAndCheckHttpResponse.ts
Expand Up @@ -84,6 +84,9 @@ export async function readMultipartBody<
if (isApolloPayloadResult(result)) {
let next = {};
if ("payload" in result) {
if (Object.keys(result).length === 1 && result.payload === null) {
return;
}
next = { ...result.payload };
}
if ("errors" in result) {
Expand Down

0 comments on commit 50b1097

Please sign in to comment.