Skip to content

Commit 6aa2f3e

Browse files
authored
turn queryRef symbols into Symbol.for calls (#12409)
* turn queryRef symbols into `Symbol.for` calls * Clean up Prettier, Size-limit, and Api-Extractor --------- Co-authored-by: phryneas <4282439+phryneas@users.noreply.github.com>
1 parent 4332b88 commit 6aa2f3e

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

.changeset/grumpy-dogs-add.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@apollo/client": patch
3+
---
4+
5+
To mitigate problems when Apollo Client ends up more than once in the bundle, some unique symbols were converted into `Symbol.for` calls.

.size-limits.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"dist/apollo-client.min.cjs": 42231,
2+
"dist/apollo-client.min.cjs": 42243,
33
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 34437
44
}

src/react/hooks/useLazyQuery.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as React from "rehackt";
55
import type {
66
ApolloClient,
77
ApolloQueryResult,
8+
ObservableQuery,
89
OperationVariables,
910
WatchQueryOptions,
1011
} from "../../core/index.js";
@@ -17,7 +18,7 @@ import type {
1718
QueryHookOptions,
1819
QueryResult,
1920
} from "../types/types.js";
20-
import type { InternalResult, ObsQueryWithMeta } from "./useQuery.js";
21+
import type { InternalResult } from "./useQuery.js";
2122
import {
2223
createMakeWatchQueryOptions,
2324
getDefaultFetchPolicy,
@@ -203,7 +204,7 @@ export function useLazyQuery<
203204

204205
function executeQuery<TData, TVariables extends OperationVariables>(
205206
resultData: InternalResult<TData, TVariables>,
206-
observable: ObsQueryWithMeta<TData, TVariables>,
207+
observable: ObservableQuery<TData, TVariables>,
207208
client: ApolloClient<object>,
208209
currentQuery: DocumentNode,
209210
options: QueryHookOptions<TData, TVariables> & {

src/react/hooks/useQuery.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ type InternalQueryResult<TData, TVariables extends OperationVariables> = Omit<
6868
>;
6969

7070
function noop() {}
71-
export const lastWatchOptions = Symbol();
71+
const lastWatchOptions = Symbol();
7272

73-
export interface ObsQueryWithMeta<TData, TVariables extends OperationVariables>
73+
interface ObsQueryWithMeta<TData, TVariables extends OperationVariables>
7474
extends ObservableQuery<TData, TVariables> {
7575
[lastWatchOptions]?: WatchQueryOptions<TVariables, TData>;
7676
}

src/react/internal/cache/QueryReference.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ type FetchMoreOptions<TData> = Parameters<
2929
ObservableQuery<TData>["fetchMore"]
3030
>[0];
3131

32-
const QUERY_REFERENCE_SYMBOL: unique symbol = Symbol();
33-
const PROMISE_SYMBOL: unique symbol = Symbol();
32+
const QUERY_REFERENCE_SYMBOL: unique symbol = Symbol.for(
33+
"apollo.internal.queryRef"
34+
);
35+
const PROMISE_SYMBOL: unique symbol = Symbol.for("apollo.internal.refPromise");
3436
declare const QUERY_REF_BRAND: unique symbol;
3537
/**
3638
* A `QueryReference` is an opaque object returned by `useBackgroundQuery`.

0 commit comments

Comments
 (0)