Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Mar 5, 2024
1 parent 39a4bfd commit 42ea24a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function WrapApolloProvider<ExtraProps>(
onQueryEvent={(event) =>
event.type === "started"
? clientRef.current!.onQueryStarted!(event)
: clientRef.current?.onQueryProgress!(event)
: clientRef.current!.onQueryProgress!(event)
}
rerunSimulatedQueries={clientRef.current.rerunSimulatedQueries}
registerDispatchRequestStarted={
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Suspense, useMemo } from "react";
import { runInConditions, testIn } from "../util/runInConditions.js";
import type {
Cache,
TypedDocumentNode,
WatchQueryOptions,
} from "@apollo/client/index.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type {
WatchQueryOptions,
FetchResult,
DocumentNode,
Cache,
} from "@apollo/client/index.js";
import {
ApolloClient as OrigApolloClient,
Expand Down Expand Up @@ -151,7 +150,7 @@ export class ApolloClientBrowserImpl<
return { query: serverQuery, cacheKey, varJson: canonicalVariables };
}

protected onQueryStarted = ({
onQueryStarted = ({
options,
id,
}: Extract<QueryEvent, { type: "started" }>) => {
Expand Down Expand Up @@ -220,9 +219,7 @@ export class ApolloClientBrowserImpl<
}
};

protected onQueryProgress = (
event: Exclude<QueryEvent, { type: "started" }>
) => {
onQueryProgress = (event: Exclude<QueryEvent, { type: "started" }>) => {
const queryInfo = this.simulatedStreamingQueries.get(event.id);

if (event.type === "data") {
Expand Down Expand Up @@ -267,7 +264,7 @@ export class ApolloClientBrowserImpl<
* simulated server-side queries going on.
* Those queries will be cancelled and then re-run in the browser.
*/
protected rerunSimulatedQueries = () => {
rerunSimulatedQueries = () => {
for (const [id, queryInfo] of this.simulatedStreamingQueries) {
this.simulatedStreamingQueries.delete(id);
invariant.debug(
Expand All @@ -277,7 +274,7 @@ export class ApolloClientBrowserImpl<
this.rerunSimulatedQuery(queryInfo);
}
};
protected rerunSimulatedQuery = (queryInfo: SimulatedQueryInfo) => {
rerunSimulatedQuery = (queryInfo: SimulatedQueryInfo) => {
const queryManager = getQueryManager(this);
const queryId = queryManager.generateQueryId();
queryManager
Expand All @@ -293,24 +290,9 @@ export class ApolloClientBrowserImpl<
};
}

export type ApolloClient<TCacheShape> = OrigApolloClient<TCacheShape> & {
onQueryStarted?: ApolloClientBrowserImpl<TCacheShape>["onQueryStarted"];
onQueryProgress?: ApolloClientBrowserImpl<TCacheShape>["onQueryProgress"];
rerunSimulatedQueries?: ApolloClientBrowserImpl<TCacheShape>["rerunSimulatedQueries"];

watchQueryQueue: {
register?: (
instance:
| ((_: {
event: Extract<QueryEvent, { type: "started" }>;
observable: Observable<Exclude<QueryEvent, { type: "started" }>>;
}) => void)
| null
) => void;
};

cache: InMemoryCache;
};
export type ApolloClient<TCacheShape> = OrigApolloClient<TCacheShape> &
Partial<ApolloClientBrowserImpl<TCacheShape>> &
Partial<ApolloClientSSRImpl<TCacheShape>>;

export const ApolloClient: {
new <TCacheShape>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export interface RehydrationContextValue {
* transported over to the client - the purpose of this
* variable is to prevent the same data being sent over
* again and again.
* (TODO: Not used yet.)
*/
transportedValues: RehydrationCache;
/**
Expand All @@ -31,7 +30,7 @@ export interface RehydrationContextValue {
*/
transportValueData: RehydrationCache;
/**
* Contains results that came in from a link that should
* Contains events that came in from a link that should
* be replayed on the client.
*/
incomingEvents: QueryEvent[];
Expand Down

0 comments on commit 42ea24a

Please sign in to comment.