From 54f35691dbf49d8770c33a119e56221e2c955c96 Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Mon, 15 Apr 2024 16:12:24 +0200 Subject: [PATCH] `gql(print(gql` --- .../src/DataTransportAbstraction/WrappedApolloClient.tsx | 5 +---- .../src/DataTransportAbstraction/transportedOptions.ts | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/client-react-streaming/src/DataTransportAbstraction/WrappedApolloClient.tsx b/packages/client-react-streaming/src/DataTransportAbstraction/WrappedApolloClient.tsx index 8e62c87a..e937e5c0 100644 --- a/packages/client-react-streaming/src/DataTransportAbstraction/WrappedApolloClient.tsx +++ b/packages/client-react-streaming/src/DataTransportAbstraction/WrappedApolloClient.tsx @@ -123,10 +123,7 @@ export class ApolloClientClientBaseImpl< } onQueryStarted({ options, id }: Extract) { - const hydratedOptions = { - ...options, - query: gql(options.query), - }; + const hydratedOptions = deserializeOptions(options); const { cacheKey, cacheKeyArr } = this.identifyUniqueQuery(hydratedOptions); this.transportedQueryOptions.set(id, hydratedOptions); diff --git a/packages/client-react-streaming/src/DataTransportAbstraction/transportedOptions.ts b/packages/client-react-streaming/src/DataTransportAbstraction/transportedOptions.ts index a6477a7f..222adaed 100644 --- a/packages/client-react-streaming/src/DataTransportAbstraction/transportedOptions.ts +++ b/packages/client-react-streaming/src/DataTransportAbstraction/transportedOptions.ts @@ -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))), }; }