Skip to content

Commit f2d469e

Browse files
authored
Fix explorer infinite loading when errors are returned (#1722)
1 parent f9512fa commit f2d469e

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

.changeset/yellow-eyes-look.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"apollo-client-devtools": patch
3+
---
4+
5+
Fix an issue where executing a query in the explorer tab that returned errors would get stuck in the loading state indefinitely.

package-lock.json

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
},
3737
"dependencies": {
3838
"@apollo/brand": "^0.7.0",
39-
"@apollo/client": "4.0.3",
39+
"@apollo/client": "4.0.5",
4040
"@apollo/client-3": "npm:@apollo/client@3.14.0",
4141
"@apollo/icons": "^0.8.0",
4242
"@apollo/tailwind-preset": "^0.2.0",

src/extension/tab/v4/handler.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type {
33
CombinedProtocolErrors,
44
LocalStateError,
55
} from "@apollo/client";
6+
import { isNetworkRequestSettled } from "@apollo/client/utilities";
67
import type {
78
ApolloClient,
89
DocumentNode,
@@ -98,7 +99,11 @@ export class ClientV4Handler extends ClientHandler<ApolloClient> {
9899
fetchPolicy: FetchPolicy;
99100
}): Observable<EmbeddedExplorerResponse> {
100101
return this.client.watchQuery<JSONObject>(options).pipe(
101-
filter((result) => result.dataState !== "empty"),
102+
filter(
103+
(result) =>
104+
isNetworkRequestSettled(result.networkStatus) ||
105+
result.dataState !== "empty"
106+
),
102107
map(
103108
(result): EmbeddedExplorerResponse => ({
104109
data: result.data,
@@ -333,14 +338,15 @@ function getErrorProperties(error: unknown): EmbeddedExplorerResponse {
333338
if (isBranded(error, "CombinedGraphQLErrors")) {
334339
return {
335340
data: error.data,
336-
error,
337341
errors: error.errors,
338342
extensions: error.extensions,
339343
};
340344
}
341345

342346
if (isErrorLike(error)) {
343-
return { error };
347+
return {
348+
error: { message: error.message, stack: error.stack },
349+
};
344350
}
345351

346352
return {};

0 commit comments

Comments
 (0)