Skip to content

Commit

Permalink
JSON parse/stringify cache data in queries to avoid serialization err…
Browse files Browse the repository at this point in the history
…or (#1481)

* json parse/stringify cache data in queries to avoid serialization error

* Add changeset
  • Loading branch information
jerelmiller committed Aug 23, 2024
1 parent ba6cefd commit d065fca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/little-otters-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"apollo-client-devtools": patch
---

Fix issue serializing cache data for the queries tab when the cache contains irregular data.
3 changes: 2 additions & 1 deletion src/extension/tab/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { getPrivateAccess } from "../../privateAccess";
import { getOperationName } from "@apollo/client/utilities";
import { pick } from "../../application/utilities/pick";
import type { GraphQLFormattedError } from "graphql";
import type { JSONObject } from "../../application/types/json";

export type QueryOptions = Pick<
WatchQueryOptions,
Expand Down Expand Up @@ -84,7 +85,7 @@ export function getQueries(
id: queryId,
document,
variables,
cachedData: diff.result,
cachedData: JSON.parse(JSON.stringify(diff.result ?? {})) as JSONObject,
options: getQueryOptions(oc),
networkStatus,
error: error ? serializeApolloError(error) : undefined,
Expand Down

0 comments on commit d065fca

Please sign in to comment.