UNPKG

@apollo/client-react-streaming

Version:

This package provides building blocks to create framework-level integration of Apollo Client with React's streaming SSR. See the [@apollo/client-integration-nextjs](https://github.com/apollographql/apollo-client-integrations/tree/main/packages/nextjs) pac

98 lines 4.06 kB
import type { OperationVariables } from "@apollo/client"; import { ApolloLink, ApolloClient as OrigApolloClient, Observable } from "@apollo/client"; import type { InMemoryCache } from "./WrappedInMemoryCache.js"; import type { ProgressEvent, QueryEvent } from "./DataTransportAbstraction.js"; import { sourceSymbol } from "../bundleInfo.js"; import type { ReadableStreamLinkEvent } from "../ReadableStreamLink.js"; type SimulatedQueryInfo = { controller: ReadableStreamDefaultController<ReadableStreamLinkEvent>; options: OrigApolloClient.WatchQueryOptions<any, OperationVariables>; }; /** @public */ export declare namespace ApolloClient { /** @public */ interface Options extends Omit<OrigApolloClient.Options, "cache" | "ssrMode" | "ssrForceFetchDelay"> { cache: InMemoryCache; } } declare class ApolloClientBase extends OrigApolloClient { /** * Information about the current package and it's export names, for use in error messages. * * @internal */ static readonly info: { pkg: string; }; [sourceSymbol]: string; constructor(options: ApolloClient.Options); setLink(newLink: ApolloLink): void; } declare class ApolloClientClientBaseImpl extends ApolloClientBase { constructor(options: ApolloClient.Options); private simulatedStreamingQueries; onQueryStarted({ options, id }: Extract<QueryEvent, { type: "started"; }>): void; onQueryProgress: (event: ProgressEvent) => void; /** * Can be called when the stream closed unexpectedly while there might still be unresolved * simulated server-side queries going on. * Those queries will be cancelled and then re-run in the browser. */ rerunSimulatedQueries: () => void; rerunSimulatedQuery: (queryInfo: SimulatedQueryInfo) => void; } declare const skipDataTransportKey: unique symbol; interface InternalContext { [skipDataTransportKey]?: boolean; } /** * Apply to a context to prevent this operation from being transported over the SSR data transport mechanism. * @public */ export declare function skipDataTransport<T extends Record<string, any>>(context: T): T & InternalContext; declare class ApolloClientSSRImpl extends ApolloClientClientBaseImpl { watchQueryQueue: { push: (value: { event: Extract<QueryEvent, { type: "started"; }>; observable: Observable<Exclude<QueryEvent, { type: "started"; }>>; }) => void; register: (callback: ((value: { event: Extract<QueryEvent, { type: "started"; }>; observable: Observable<Exclude<QueryEvent, { type: "started"; }>>; }) => void) | null) => void; }; pushEventStream(options: OrigApolloClient.WatchQueryOptions<any, any>): ReadableStreamDefaultController<ReadableStreamLinkEvent>; watchQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(options: OrigApolloClient.WatchQueryOptions<TData, TVariables>): import("@apollo/client").ObservableQuery<TData, TVariables>; } declare const ApolloClient_base: typeof ApolloClientBase; /** * A version of `ApolloClient` to be used with streaming SSR or in React Server Components. * * For more documentation, please see {@link https://www.apollographql.com/docs/react/api/core/ApolloClient | the Apollo Client API documentation}. * * @public */ export declare class ApolloClient extends ApolloClient_base implements Partial<ApolloClientSSRImpl> { /** @internal */ onQueryStarted?: ApolloClientSSRImpl["onQueryStarted"]; /** @internal */ onQueryProgress?: ApolloClientSSRImpl["onQueryProgress"]; /** @internal */ rerunSimulatedQueries?: ApolloClientSSRImpl["rerunSimulatedQueries"]; /** @internal */ rerunSimulatedQuery?: ApolloClientSSRImpl["rerunSimulatedQuery"]; /** @internal */ watchQueryQueue?: ApolloClientSSRImpl["watchQueryQueue"]; } export {}; //# sourceMappingURL=WrappedApolloClient.d.ts.map