Skip to content

Commit

Permalink
gql(print(gql
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Apr 15, 2024
1 parent 4eb91c7 commit 54f3569
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ export class ApolloClientClientBaseImpl<
}

onQueryStarted({ options, id }: Extract<QueryEvent, { type: "started" }>) {
const hydratedOptions = {
...options,
query: gql(options.query),
};
const hydratedOptions = deserializeOptions(options);
const { cacheKey, cacheKeyArr } = this.identifyUniqueQuery(hydratedOptions);
this.transportedQueryOptions.set(id, hydratedOptions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ export function deserializeOptions(
): WatchQueryOptions {
return {
...options,
query: gql(options.query),
// `gql` memoizes results, but based on the input string.
// We parse-stringify-parse here to ensure that our minified query
// has the best chance of being the referential same query as the one used in
// client-side code.
query: gql(print(gql(options.query))),
};
}

Expand Down

0 comments on commit 54f3569

Please sign in to comment.