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

1 lines 74.8 kB
{"version":3,"sources":["../src/registerApolloClient.tsx","../src/PreloadQuery.tsx","../src/transportedQueryRef.ts","../src/ReadableStreamLink.tsx","../src/DataTransportAbstraction/WrappedInMemoryCache.tsx","../src/bundleInfo.ts","../src/DataTransportAbstraction/WrappedApolloClient.tsx","../src/DataTransportAbstraction/useTransportValue.tsx","../src/DataTransportAbstraction/DataTransportAbstraction.ts","../src/DataTransportAbstraction/hooks.ts","../src/DataTransportAbstraction/transportedOptions.ts","../src/assertInstance.ts","../src/DataTransportAbstraction/WrapApolloProvider.tsx","../src/AccumulateMultipartResponsesLink.ts","../src/RemoveMultipartDirectivesLink.ts","../src/SSRMultipartLink.ts"],"names":["React","reader","ApolloLink","Observable","invariant","PreloadQuery"],"mappings":";AACA,OAAOA,YAAW;AAClB,SAAS,aAAa;;;ACFtB,SAAS,8BAA8B;AAQvC,OAAOA,YAAW;;;ACRlB,SAAS,gBAAgB,oBAAoB;;;ACA7C,SAAS,YAAY,kBAAkB;AA4BvC,IAAM,yBAAyB,OAAO;AAAA,EACpC;AACF;AACA,IAAM,4BAA4B,OAAO,IAAI,4BAA4B;AAMlE,SAAS,oBACd,WACA,SACqB;AACrB,SAAO,OAAO,OAAO,SAAS;AAAA,IAC5B,CAAC,sBAAsB,GAAG;AAAA,EAC5B,CAAC;AACH;AAMO,SAAS,uBACd,gBACA,SACqB;AACrB,SAAO,OAAO,OAAO,SAAS;AAAA,IAC5B,CAAC,yBAAyB,GAAG;AAAA,EAC/B,CAAC;AACH;AAOO,IAAM,0BAAN,cAAsC,WAAW;AAAA,EACtD,cAAc;AACZ,UAAM,CAAC,WAAW,YAAY;AAC5B,YAAM,UAAU,UAAU,WAAW;AAErC,YAAM,YAAY,QAAQ,sBAAsB;AAEhD,UAAI,W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A,UAAM,EAAE,MAAM,IAAI;AAElB,QAAI,gBAAqC;AACzC,oBAAgB;AAAA,MACd,KAAK,gBACF;AAAA,QACC,CAAC,eAAe;AAAA,UACd,KAAK,MAAM;AACT,gBAAI,cACF,KAAK,SAAS,eAAe,KAAK,KAAK,UAAU;AACnD,kBAAM,QAAQ,0BAA0B,MAAM,OAAO;AACrD,gBACE,OAAO,SAAS,iBAChB,MAAM,MAAM,WAAW,cAAc,GACrC;AACA,4BAAc;AAAA,YAChB;AACA,mBAAO;AAAA,UACT;AAAA,UACA,QAAQ;AAAA,QACV;AAAA,MACF,EACC,OAAO;AAAA,QACN,KAAK,MAAM;AACT,cAAI,KAAK,SAAS;AAAa,mBAAO;AACtC,gBAAM,QAAQ,0BAA0B,MAAM,OAAO;AACrD,iBACE,OAAO,SAAS,iBAChB,MAAM,MAAM,WAAW,UAAU;AAAA,QAErC;AAAA,QACA,QAAQ;AAAA,MACV,CAAC;AAAA,MACH;AAAA,IACF;AAEA,QAAI,kBAAkB,MAAM;AAC1B,aAAO,GAAG,CAAC,CAAC;AAAA,IACd;AAEA,cAAU,QAAQ;AAElB,WAAO,QAAQ,SAAS;AAAA,EAC1B;AACF;;;AC1HA,SAAS,cAAAA,mBAAkB;AAuDpB,IAAM,mBAAN,cAA+BA,YAAW;AAAA,EAC/C,YAAY,SAAiC,CAAC,GAAG;AAC/C,UAAM,WAAWA,YAAW,KAAK;AAAA,MAC/B,IAAI,8BAA8B;AAAA,QAChC,YAAY,OAAO;AAAA,MACrB,CAAC;AAAA,MACD,IAAI,iCAAiC;AAAA,QACnC,aAAa,OAAO,eAAe;AAAA,MACrC,CAAC;AAAA,IACH,CAAC;AACD,UAAM,SAAS,OAAO;AAAA,EACxB;AACF","sourcesContent":["import type { ApolloClient, OperationVariables } from \"@apollo/client\";\nimport React from \"react\";\nimport { cache } from \"react\";\nimport type { PreloadQuery } from \"./PreloadQuery.js\";\nimport { PreloadQuery as UnboundPreloadQuery } from \"./PreloadQuery.js\";\n\nconst seenWrappers = WeakSet\n ? new WeakSet<{ client: ApolloClient | Promise<ApolloClient> }>()\n : undefined;\nconst seenClients = WeakSet\n ? new WeakSet<ApolloClient | Promise<ApolloClient>>()\n : undefined;\n\nconst checkForStableCache = cache(() => ({}));\n\n/**\n * > This export is only available in React Server Components\n *\n * Ensures that you can always access the same instance of ApolloClient\n * during RSC for an ongoing request, while always returning\n * a new instance for different requests.\n *\n * @example\n * ```ts\n * export const { getClient, query, PreloadQuery } = registerApolloClient(() => {\n * return new ApolloClient({\n * cache: new InMemoryCache(),\n * link: new HttpLink({\n * uri: \"http://example.com/api/graphql\",\n * }),\n * });\n * });\n * ```\n *\n * @public\n */\nexport function registerApolloClient<\n ApolloClientOrPromise extends Promise<ApolloClient> | ApolloClient,\n>(\n makeClient: () => ApolloClientOrPromise\n): {\n getClient: () => ApolloClientOrPromise;\n query: Awaited<ApolloClientOrPromise>[\"query\"];\n /**\n * Preloads data in React Server Components to be hydrated\n * in Client Components.\n *\n * ### Example with `queryRef`\n * `ClientChild` would call `useReadQuery` with the `queryRef`, the `Suspense` boundary is optional:\n * ```jsx\n * <PreloadQuery\n * query={QUERY}\n * variables={{\n * foo: 1\n * }}\n * >\n * {(queryRef) => (\n * <Suspense fallback={<>loading</>}>\n * <ClientChild queryRef={queryRef} />\n * </Suspense>\n * )}\n * </PreloadQuery>\n * ```\n *\n * ### Example for `useSuspenseQuery`\n * `ClientChild` would call the same query with `useSuspenseQuery`, the `Suspense` boundary is optional:\n * ```jsx\n * <PreloadQuery\n * query={QUERY}\n * variables={{\n * foo: 1\n * }}\n * >\n * <Suspense fallback={<>loading</>}>\n * <ClientChild />\n * </Suspense>\n * </PreloadQuery>\n * ```\n */\n PreloadQuery: PreloadQueryComponent;\n} {\n const getClient = makeGetClient(makeClient);\n /*\n We create an independent instance of Apollo Client per request,\n because we don't want to mix up RSC-specific data with Client-specific\n data in the same `InMemoryCache` instance.\n */\n const getPreloadClient = makeGetClient(makeClient);\n const PreloadQuery = makePreloadQuery(getPreloadClient);\n return {\n getClient,\n query: async (...args) => {\n if (checkForStableCache() !== checkForStableCache()) {\n console.warn(\n `\nThe \\`query\\` shortcut returned from \\`registerApolloClient\\` \nshould not be used in Server Action or Middleware environments.\n\nCalling it multiple times in those environments would \ncreate multiple independent \\`ApolloClient\\` instances.\n\nPlease create a single \\`ApolloClient\\` instance by calling \n\\`getClient()\\` at the beginning of your Server Action or Middleware \nfunction and then call \\`client.query\\` multiple times instead.\n `.trim()\n );\n }\n return (await getClient()).query(...args);\n },\n PreloadQuery,\n };\n}\n\nfunction makeGetClient<AC extends Promise<ApolloClient> | ApolloClient>(\n makeClient: () => AC\n): () => AC {\n // React invalidates the cache on each server request, so the wrapping\n // object is needed to properly detect whether the client is a unique\n // reference or not. We can warn if `cachedMakeWrappedClient` creates a new \"wrapper\",\n // but with a `client` property that we have already seen before.\n // In that case, not every call to `makeClient` would create a new\n // `ApolloClient` instance.\n function makeWrappedClient() {\n return { client: makeClient() };\n }\n\n const cachedMakeWrappedClient = cache(makeWrappedClient);\n\n function getClient() {\n if (arguments.length) {\n throw new Error(\n `\nYou cannot pass arguments into \\`getClient\\`.\nPassing arguments to \\`getClient\\` returns a different instance\nof Apollo Client each time it is called with different arguments, potentially \nresulting in duplicate requests and a non-functional cache. \n `.trim()\n );\n }\n const wrapper = cachedMakeWrappedClient();\n if (seenWrappers && seenClients) {\n if (!seenWrappers.has(wrapper)) {\n if (seenClients.has(wrapper.client)) {\n console.warn(\n `\nMultiple calls to \\`getClient\\` for different requests returned the same client instance.\nThis means that private user data could accidentally be shared between requests.\nThis happens, for example, if you create a global \\`ApolloClient\\` instance and your \\`makeClient\\`\nimplementation just looks like \\`() => client\\`.\nAlways call \\`new ApolloClient\\` **inside** your \\`makeClient\\` function and\nreturn a new instance every time \\`makeClient\\` is called.\n`.trim()\n );\n }\n seenWrappers.add(wrapper);\n seenClients.add(wrapper.client);\n }\n }\n return wrapper.client;\n }\n return getClient;\n}\n\n/**\n * @deprecated use `PreloadQuery.Props` instead\n * @public\n */\nexport type PreloadQueryProps<\n TData,\n TVariables extends OperationVariables,\n> = PreloadQuery.Props<TData, TVariables>;\n\n/**\n * Preloads data in React Server Components to be hydrated\n * in Client Components.\n *\n * ### Example with `queryRef`\n * `ClientChild` would call `useReadQuery` with the `queryRef`, the `Suspense` boundary is optional:\n * ```jsx\n * <PreloadQuery\n * query={QUERY}\n * variables={{\n * foo: 1\n * }}\n * >\n * {(queryRef) => (\n * <Suspense fallback={<>loading</>}>\n * <ClientChild queryRef={queryRef} />\n * </Suspense>\n * )}\n * </PreloadQuery>\n * ```\n *\n * ### Example for `useSuspenseQuery`\n * `ClientChild` would call the same query with `useSuspenseQuery`, the `Suspense` boundary is optional:\n * ```jsx\n * <PreloadQuery\n * query={QUERY}\n * variables={{\n * foo: 1\n * }}\n * >\n * <Suspense fallback={<>loading</>}>\n * <ClientChild />\n * </Suspense>\n * </PreloadQuery>\n * ```\n *\n * @public\n */\nexport interface PreloadQueryComponent {\n <TData, TVariables extends OperationVariables>(\n props: PreloadQuery.Props<TData, TVariables>\n ): React.ReactElement;\n}\n\nfunction makePreloadQuery(\n getClient: () => Promise<ApolloClient> | ApolloClient\n) {\n return function PreloadQuery<TData, TVariables extends OperationVariables>(\n props: PreloadQuery.Props<TData, TVariables>\n ): React.ReactElement {\n return <UnboundPreloadQuery getClient={getClient} {...props} />;\n };\n}\n","import { SimulatePreloadedQuery } from \"./index.cc.js\";\nimport type {\n ApolloClient,\n DocumentNode,\n OperationVariables,\n TypedDocumentNode,\n} from \"@apollo/client\";\nimport type { ReactNode } from \"react\";\nimport React from \"react\";\nimport type {\n PreloadTransportedQueryOptions,\n TransportedQueryRef,\n} from \"./transportedQueryRef.js\";\nimport { createTransportedQueryPreloader } from \"./transportedQueryRef.js\";\n\n/** @deprecated use `PreloadQuery.Options` instead */\nexport type PreloadQueryOptions<\n TVariables extends OperationVariables,\n TData,\n> = PreloadQuery.Options<TData, TVariables>;\nexport declare namespace PreloadQuery {\n export type Options<\n TData,\n TVariables extends OperationVariables,\n > = PreloadTransportedQueryOptions<TData, TVariables> & {\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n };\n\n export type Props<\n TData,\n TVariables extends OperationVariables,\n > = PreloadQuery.Options<TData, TVariables> & {\n children:\n | ReactNode\n | ((\n queryRef: TransportedQueryRef<NoInfer<TData>, NoInfer<TVariables>>\n ) => ReactNode);\n };\n}\n\nexport async function PreloadQuery<\n TData,\n TVariables extends OperationVariables,\n>({\n getClient,\n children,\n query,\n ...transportedOptions\n}: PreloadQuery.Props<TData, TVariables> & {\n getClient: () => ApolloClient | Promise<ApolloClient>;\n}): Promise<React.ReactElement> {\n const preloader = createTransportedQueryPreloader(await getClient(), {\n notTransportedOptionOverrides: { fetchPolicy: \"no-cache\" },\n });\n const queryRef = preloader(\n query,\n transportedOptions as PreloadTransportedQueryOptions<TData, TVariables>\n );\n\n return (\n <SimulatePreloadedQuery<TData> queryRef={queryRef}>\n {typeof children === \"function\" ? children(queryRef) : children}\n </SimulatePreloadedQuery>\n );\n}\n","import { unwrapQueryRef, wrapQueryRef } from \"@apollo/client/react/internal\";\nimport {\n readFromReadableStream,\n teeToReadableStream,\n} from \"./ReadableStreamLink.js\";\nimport { skipDataTransport } from \"./DataTransportAbstraction/index.js\";\nimport type { ReadableStreamLinkEvent } from \"./ReadableStreamLink.js\";\nimport type { QueryRef } from \"@apollo/client/react\";\nimport { useApolloClient } from \"@apollo/client/react\";\nimport type {\n DocumentNode,\n ApolloClient,\n OperationVariables,\n TypedDocumentNode,\n} from \"@apollo/client\";\nimport {\n serializeOptions,\n deserializeOptions,\n type TransportedOptions,\n} from \"./DataTransportAbstraction/transportedOptions.js\";\nimport { useEffect } from \"react\";\nimport {\n JSONDecodeStream,\n JSONEncodeStream,\n type JsonString,\n} from \"@apollo/client-react-streaming/stream-utils\";\nimport { InternalQueryReference } from \"@apollo/client/react/internal\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\n\ntype RestrictedPreloadOptions = {\n fetchPolicy?: \"network-only\" | \"cache-and-network\" | \"cache-first\";\n returnPartialData?: false;\n nextFetchPolicy?: undefined;\n pollInterval?: undefined;\n};\n\n/** @public */\nexport type PreloadTransportedQueryOptions<\n TData,\n TVariables extends OperationVariables,\n> = Omit<ApolloClient.QueryOptions<TData, TVariables>, \"query\"> &\n RestrictedPreloadOptions;\n\ntype TransportedQueryRefOptions = TransportedOptions & RestrictedPreloadOptions;\n\n/**\n * A `TransportedQueryRef` is an opaque object accessible via renderProp within `PreloadQuery`.\n *\n * A child client component reading the `TransportedQueryRef` via useReadQuery will suspend until the promise resolves.\n *\n * @public\n */\nexport interface TransportedQueryRef<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> extends QueryRef<TData, TVariables> {\n /**\n * Temporarily disabled - see https://github.com/apollographql/apollo-client-integrations/issues/332\n *\n * Will now be be `undefined` both in React Server Components and Client Components until we can find a better resolution.\n */\n toPromise?: undefined;\n /** @internal */\n $__apollo_queryRef: {\n options: TransportedQueryRefOptions;\n stream: ReadableStream<JsonString<ReadableStreamLinkEvent>>;\n /**\n * A unique key for this query, to ensure it is only hydrated once,\n * even if it should get transported over the wire in a way that results\n * in multiple objects describing the same queryRef.\n * This key will be used to store the queryRef in the suspence cache.\n *\n * The chances of this happening should be slim (it is handled within\n * React thanks to https://github.com/facebook/react/pull/28996), but\n * as we use transported queryRefs with multiple frameworks with distinct\n * transport mechanisms, this seems like a safe option.\n */\n queryKey: string;\n };\n}\n\n/** @public */\nexport interface PreloadTransportedQueryFunction {\n <TData = unknown, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: PreloadTransportedQueryOptions<TData, NoInfer<TVariables>>\n ): TransportedQueryRef<TData, TVariables>;\n}\n\n/** @internal */\nexport function getInjectableEventStream() {\n let controller:\n | ReadableStreamDefaultController<ReadableStreamLinkEvent>\n | undefined;\n const stream = new ReadableStream<ReadableStreamLinkEvent>({\n start(c) {\n controller = c;\n },\n });\n return [controller!, stream] as const;\n}\n\n/** @public */\nexport function createTransportedQueryPreloader(\n client: ApolloClient,\n {\n prepareForReuse = false,\n notTransportedOptionOverrides = {},\n }: {\n /**\n * Set this to `true` to indicate that this `queryRef` will be reused within the same process with the same Apollo Client instance without being dehydrated and hydrated.\n * In that case, it will already be written to the suspense cache so it doesn't need to be hydrated by re-running the query with a fake network request.\n */\n prepareForReuse?: boolean;\n /**\n * Overrides to the options that should happen only in the `preloader` call, but should not be transported/hydrated on the client.\n */\n notTransportedOptionOverrides?: Partial<\n ApolloClient.WatchQueryOptions<any, any>\n >;\n } = {}\n): PreloadTransportedQueryFunction {\n return (...[query, options]: Parameters<PreloadTransportedQueryFunction>) => {\n // unset options that we do not support\n options = { ...options };\n delete options.returnPartialData;\n delete options.nextFetchPolicy;\n delete options.pollInterval;\n\n const [controller, stream] = getInjectableEventStream();\n const transportedQueryRef = createTransportedQueryRef<any, any>(\n query,\n options,\n crypto.randomUUID(),\n stream\n );\n\n const watchQueryOptions: ApolloClient.WatchQueryOptions<any, any> = {\n query,\n ...options,\n notifyOnNetworkStatusChange: false,\n context: skipDataTransport(\n teeToReadableStream(() => controller, {\n ...options?.context,\n // we want to do this even if the query is already running for another reason\n queryDeduplication: false,\n })\n ),\n ...notTransportedOptionOverrides,\n };\n if (\n watchQueryOptions.fetchPolicy !== \"no-cache\" &&\n watchQueryOptions.fetchPolicy !== \"network-only\" &&\n (!prepareForReuse ||\n watchQueryOptions.fetchPolicy !== \"cache-and-network\")\n ) {\n // ensure that this query makes it to the network\n watchQueryOptions.fetchPolicy = \"network-only\";\n }\n\n if (prepareForReuse) {\n const internalQueryRef = getInternalQueryRef(\n client,\n { query, ...options },\n watchQueryOptions\n );\n\n return Object.assign(transportedQueryRef, wrapQueryRef(internalQueryRef));\n } else {\n const subscription = client.watchQuery(watchQueryOptions).subscribe({\n next() {\n subscription.unsubscribe();\n },\n });\n }\n\n return transportedQueryRef;\n };\n}\n\nfunction createTransportedQueryRef<\n TData,\n TVariables extends OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: PreloadTransportedQueryOptions<TData, NoInfer<TVariables>>,\n queryKey: string,\n stream: ReadableStream<ReadableStreamLinkEvent>\n): TransportedQueryRef<TData, TVariables> {\n return {\n $__apollo_queryRef: {\n options: sanitizeForTransport(serializeOptions({ query, ...options })),\n queryKey,\n stream: stream.pipeThrough(new JSONEncodeStream()),\n },\n };\n}\n\n/** @public */\nexport function reviveTransportedQueryRef(\n queryRef: TransportedQueryRef,\n client: ApolloClient\n): asserts queryRef is TransportedQueryRef & ReturnType<typeof wrapQueryRef> {\n if (unwrapQueryRef(queryRef)) return;\n const {\n $__apollo_queryRef: { options, stream },\n } = queryRef;\n const hydratedOptions = deserializeOptions(options);\n const internalQueryRef = getInternalQueryRef(client, hydratedOptions, {\n ...hydratedOptions,\n fetchPolicy: \"network-only\",\n context: skipDataTransport(\n readFromReadableStream(stream.pipeThrough(new JSONDecodeStream()), {\n ...hydratedOptions.context,\n queryDeduplication: true,\n })\n ),\n });\n Object.assign(queryRef, wrapQueryRef(internalQueryRef));\n}\n\nfunction getInternalQueryRef(\n client: ApolloClient,\n userOptions: ApolloClient.WatchQueryOptions,\n initialFetchOptions: ApolloClient.WatchQueryOptions\n) {\n if (__DEV__) {\n // this would be a bug in our code, `initialFetchOptions` should always be derived\n // from `userOptions` and never change `nextFetchPolicy` or we would need additional\n // logic to handle that case\n invariant(\n userOptions.nextFetchPolicy === initialFetchOptions.nextFetchPolicy,\n \"Encountered an unexpected bug in @apollo/client-react-streaming. Please file an issue.\"\n );\n }\n // create with `userOptions` so internals like `initialFetchPolicy` are set correctly\n const observable = client.watchQuery(userOptions);\n // this might have filled in some defaults, so we need to capture them\n const optionsAfterCreation = {\n // context might still be `undefined`, so we need to make sure the property is at least present\n // `undefined` won't merge in as `applyOptions` uses `compact`, so we use an empty object instead\n context: {},\n ...observable.options,\n };\n // apply `initialFetchOptions` for the first fetch\n observable.applyOptions(initialFetchOptions);\n // `new InternalQueryReference` calls `observable.subscribe` immediately, so the `initialFetchOptions` are applied to that call\n const internalQueryRef = new InternalQueryReference(observable, {\n autoDisposeTimeoutMs:\n client.defaultOptions.react?.suspense?.autoDisposeTimeoutMs,\n });\n // set the options for any future `reobserve` calls back to `userOptions` directly after that\n observable.applyOptions({\n ...optionsAfterCreation,\n fetchPolicy:\n observable.options.fetchPolicy === initialFetchOptions.fetchPolicy\n ? // restore `userOptions.fetchPolicy` for future fetches\n optionsAfterCreation.fetchPolicy\n : // otherwise `fetchPolicy` was changed from `initialFetchOptions`, `nextFetchPolicy` has been applied and we're not going to touch it\n observable.options.fetchPolicy,\n });\n return internalQueryRef;\n}\n\n/** @public */\nexport function isTransportedQueryRef(\n queryRef: any\n): queryRef is TransportedQueryRef {\n return !!(queryRef && queryRef.$__apollo_queryRef);\n}\n\n/** @public */\n// This hook is injected into `useReadQuery` and `useQueryRefHandlers` to ensure that\n// `TransportedQueryRef`s are properly revived into `WrappedQueryRef`s before usage,\n// should they not be hydrated properly for some reason.\nexport function useWrapTransportedQueryRef<TData>(\n queryRef:\n | QueryRef<TData, any, \"complete\" | \"streaming\" | \"empty\" | \"partial\">\n | TransportedQueryRef\n): QueryRef<TData> {\n const client = useApolloClient();\n const isTransported = isTransportedQueryRef(queryRef);\n if (isTransported) {\n reviveTransportedQueryRef(queryRef, client);\n }\n const unwrapped = unwrapQueryRef(queryRef)!;\n\n // Soft-retaining because useQueryRefHandlers doesn't do it for us.\n useEffect(() => {\n if (isTransported) {\n return unwrapped.softRetain();\n }\n }, [isTransported, unwrapped]);\n return queryRef satisfies QueryRef<any, any, any> as QueryRef<TData>;\n}\n\nfunction sanitizeForTransport<T>(value: T) {\n return JSON.parse(JSON.stringify(value)) as T;\n}\n","import { ApolloLink, Observable } from \"@apollo/client\";\n\n/**\n * @internal\n */\nexport type ReadableStreamLinkEvent =\n | { type: \"next\"; value: ApolloLink.Result }\n | { type: \"completed\" }\n | { type: \"error\" };\n\n/**\n * Called when the link is hit, before the request is forwarded.\n *\n * Should return the controller for the readable stream.\n *\n * This is useful because when starting a query, it's not always\n * clear if the query will hit the network or will be served from\n * cache, deduplicated etc.\n * This allows to inject the \"start event\" into the stream only\n * when we know that more chunks will actually follow.\n */\ntype OnLinkHitFunction =\n () => ReadableStreamDefaultController<ReadableStreamLinkEvent>;\ninterface InternalContext {\n [teeToReadableStreamKey]?: OnLinkHitFunction;\n [readFromReadableStreamKey]?: ReadableStream<ReadableStreamLinkEvent>;\n}\n\nconst teeToReadableStreamKey = Symbol.for(\n \"apollo.tee.readableStreamController\"\n);\nconst readFromReadableStreamKey = Symbol.for(\"apollo.read.readableStream\");\n\n/**\n * Apply to a context that will be passed to a link chain containing `TeeToReadableStreamLink`.\n * @public\n */\nexport function teeToReadableStream<T extends Record<string, any>>(\n onLinkHit: OnLinkHitFunction,\n context: T\n): T & InternalContext {\n return Object.assign(context, {\n [teeToReadableStreamKey]: onLinkHit,\n });\n}\n\n/**\n * Apply to a context that will be passed to a link chain containing `ReadFromReadableStreamLink`.\n * @public\n */\nexport function readFromReadableStream<T extends Record<string, any>>(\n readableStream: ReadableStream<ReadableStreamLinkEvent>,\n context: T\n): T & InternalContext {\n return Object.assign(context, {\n [readFromReadableStreamKey]: readableStream,\n });\n}\n\n/**\n * A link that allows the request to be cloned into a readable stream, e.g. for\n * transport of multipart responses from RSC or a server loader to the browser.\n * @public\n */\nexport class TeeToReadableStreamLink extends ApolloLink {\n constructor() {\n super((operation, forward) => {\n const context = operation.getContext() as InternalContext;\n\n const onLinkHit = context[teeToReadableStreamKey];\n\n if (onLinkHit) {\n const controller = onLinkHit();\n\n const tryClose = () => {\n try {\n controller.close();\n } catch {\n // maybe we already tried to close the stream, nothing to worry about\n }\n };\n return new Observable((observer) => {\n let subscribed = true;\n forward(operation).subscribe({\n next(result) {\n controller.enqueue({ type: \"next\", value: result });\n if (subscribed) {\n observer.next(result);\n }\n },\n error(error) {\n controller.enqueue({ type: \"error\" });\n tryClose();\n if (subscribed) {\n observer.error(error);\n }\n },\n complete() {\n controller.enqueue({ type: \"completed\" });\n tryClose();\n if (subscribed) {\n observer.complete();\n }\n },\n });\n\n return () => {\n subscribed = false;\n };\n });\n }\n\n return forward(operation);\n });\n }\n}\n\n/**\n * A link that allows the response to be read from a readable stream, e.g. for\n * hydration of a multipart response from RSC or a server loader in the browser.\n * @public\n */\nexport class ReadFromReadableStreamLink extends ApolloLink {\n constructor() {\n super((operation, forward) => {\n const context = operation.getContext() as InternalContext;\n\n const eventSteam = context[readFromReadableStreamKey];\n if (eventSteam) {\n return new Observable((observer) => {\n let aborted = false as boolean;\n const reader = (() => {\n try {\n return eventSteam.getReader();\n } catch {\n /**\n * The reader could not be created, usually because the stream has\n * already been consumed.\n * This would be the case if we call `refetch` on a queryRef that has\n * the `readFromReadableStreamKey` property in context.\n * In that case, we want to do a normal network request.\n */\n }\n })();\n\n if (!reader) {\n // if we can't create a reader, we want to do a normal network request\n const subscription = forward(operation).subscribe(observer);\n return () => subscription.unsubscribe();\n }\n let forwarded = false;\n consume(reader).finally(() => {\n // in case the stream ends without a `completed` event we still need to close the observer\n // to avoid an the observable never being removed from `inFlightLinkObservables`\n if (!observer.closed && !forwarded) {\n observer.complete();\n }\n });\n let onAbort = () => {\n aborted = true;\n reader.cancel();\n };\n\n return () => onAbort();\n\n async function consume(\n reader: ReadableStreamDefaultReader<ReadableStreamLinkEvent>\n ) {\n let event:\n | ReadableStreamReadResult<ReadableStreamLinkEvent>\n | undefined = undefined;\n while (!aborted && !event?.done) {\n event = await reader.read();\n if (aborted) break;\n if (event.value) {\n switch (event.value.type) {\n case \"next\":\n observer.next(event.value.value);\n break;\n case \"completed\":\n observer.complete();\n break;\n case \"error\":\n // in case a network error happened on the sending side,\n if (process.env.REACT_ENV === \"ssr\") {\n // we want to fail SSR for this tree\n observer.error(\n new Error(\n \"Error from event stream. Redacted for security concerns.\"\n )\n );\n } else {\n // we want to retry the operation on the receiving side\n onAbort();\n forwarded = true;\n const subscription =\n forward(operation).subscribe(observer);\n onAbort = () => subscription.unsubscribe();\n }\n break;\n }\n }\n }\n }\n });\n }\n\n return forward(operation);\n });\n }\n}\n","import type { InMemoryCacheConfig } from \"@apollo/client\";\nimport { InMemoryCache as OrigInMemoryCache } from \"@apollo/client\";\nimport { bundle, sourceSymbol } from \"../bundleInfo.js\";\n/*\n * We just subclass `InMemoryCache` here so that `WrappedApolloClient`\n * can detect if it was initialized with an `InMemoryCache` instance that\n * was also exported from this package.\n * Right now, we don't have extra logic here, but we might have so again\n * in the future.\n * So we want to enforce this import path from the start to prevent future\n * subtle bugs if people update the package and don't read the patch notes.\n */\n/**\n * A version of `InMemoryCache` to be used with streaming SSR.\n *\n * For more documentation, please see {@link https://www.apollographql.com/docs/react/api/cache/InMemoryCache | the Apollo Client API documentation}.\n *\n * @public\n */\nexport class InMemoryCache extends OrigInMemoryCache {\n /**\n * Information about the current package and it's export names, for use in error messages.\n *\n * @internal\n */\n static readonly info = bundle;\n [sourceSymbol]: string;\n constructor(config?: InMemoryCacheConfig | undefined) {\n super(config);\n const info = (this.constructor as typeof InMemoryCache).info;\n this[sourceSymbol] = `${info.pkg}:InMemoryCache`;\n }\n}\n","export const bundle = {\n pkg: \"@apollo/client-react-streaming\",\n};\n\nexport const sourceSymbol = Symbol.for(\"apollo.source_package\");\n","import type { OperationVariables } from \"@apollo/client\";\n\nimport {\n ApolloLink,\n ApolloClient as OrigApolloClient,\n Observable,\n type InternalTypes,\n} from \"@apollo/client\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\nimport { createBackpressuredCallback } from \"./backpressuredCallback.js\";\nimport type { InMemoryCache } from \"./WrappedInMemoryCache.js\";\nimport { hookWrappers } from \"./hooks.js\";\nimport type { HookWrappers } from \"@apollo/client/react/internal\";\nimport type {\n ProgressEvent,\n QueryEvent,\n TransportIdentifier,\n} from \"./DataTransportAbstraction.js\";\nimport { bundle, sourceSymbol } from \"../bundleInfo.js\";\nimport { serializeOptions, deserializeOptions } from \"./transportedOptions.js\";\nimport { assertInstance } from \"../assertInstance.js\";\nimport type { ReadableStreamLinkEvent } from \"../ReadableStreamLink.js\";\nimport {\n readFromReadableStream,\n ReadFromReadableStreamLink,\n teeToReadableStream,\n TeeToReadableStreamLink,\n} from \"../ReadableStreamLink.js\";\nimport { getInjectableEventStream } from \"../transportedQueryRef.js\";\n\nfunction getQueryManager(\n client: OrigApolloClient\n): InternalTypes.QueryManager & {\n [wrappers]: HookWrappers;\n} {\n return client[\"queryManager\"];\n}\n\ntype SimulatedQueryInfo = {\n controller: ReadableStreamDefaultController<ReadableStreamLinkEvent>;\n options: OrigApolloClient.WatchQueryOptions<any, OperationVariables>;\n};\n/** @public */\nexport declare namespace ApolloClient {\n /** @public */\n export interface Options\n extends Omit<\n OrigApolloClient.Options,\n \"cache\" | \"ssrMode\" | \"ssrForceFetchDelay\"\n > {\n cache: InMemoryCache;\n }\n /*\n We can currently not re-export these types from the upstream ApolloClient implementation because the build \n tooling doesn't support that:\n > DTS Build error\n > Error: namespace child (hoisting) not supported yet\n\n We could re-export them by defining them as new types that reference the originals, but that would require us\n to keep generics in sync and would either erase the docblocks or require us to duplicate them \n (and they would go out of sync).\n If you need any of the other types, please use the `ApolloClient` namespace exported from `@apollo/client` directly.\n */\n // export import DefaultOptions = OrigApolloClient.DefaultOptions;\n // export import DevtoolsOptions = OrigApolloClient.DevtoolsOptions;\n // export import MutateOptions = OrigApolloClient.MutateOptions;\n // export import MutateResult = OrigApolloClient.MutateResult;\n // export import QueryOptions = OrigApolloClient.QueryOptions;\n // export import QueryResult = OrigApolloClient.QueryResult;\n // export import RefetchQueriesOptions = OrigApolloClient.RefetchQueriesOptions;\n // export import RefetchQueriesResult = OrigApolloClient.RefetchQueriesResult;\n // export import SubscribeOptions = OrigApolloClient.SubscribeOptions;\n // export import SubscribeResult = OrigApolloClient.SubscribeResult;\n // export import WatchFragmentOptions = OrigApolloClient.WatchFragmentOptions;\n // export import WatchFragmentResult = OrigApolloClient.WatchFragmentResult;\n // export import WatchQueryOptions = OrigApolloClient.WatchQueryOptions;\n // export import ReadQueryOptions = OrigApolloClient.ReadQueryOptions;\n // export import WriteQueryOptions = OrigApolloClient.WriteQueryOptions;\n // export import WriteFragmentOptions = OrigApolloClient.WriteFragmentOptions;\n}\n\nconst wrappers = Symbol.for(\"apollo.hook.wrappers\");\nclass ApolloClientBase extends OrigApolloClient {\n /**\n * Information about the current package and it's export names, for use in error messages.\n *\n * @internal\n */\n static readonly info = bundle;\n\n [sourceSymbol]: string;\n\n constructor(options: ApolloClient.Options) {\n const warnings: string[] = [];\n if (\"ssrMode\" in options) {\n delete options.ssrMode;\n warnings.push(\n \"The `ssrMode` option is not supported in %s. Please remove it from your %s constructor options.\"\n );\n }\n if (\"ssrForceFetchDelay\" in options) {\n delete options.ssrForceFetchDelay;\n warnings.push(\n \"The `ssrForceFetchDelay` option is not supported in %s. Please remove it from your %s constructor options.\"\n );\n }\n super(\n process.env.REACT_ENV === \"rsc\" || process.env.REACT_ENV === \"ssr\"\n ? {\n devtools: { enabled: false, ...options.devtools },\n ...options,\n }\n : options\n );\n const info = (this.constructor as typeof ApolloClientBase).info;\n this[sourceSymbol] = `${info.pkg}:ApolloClient`;\n\n for (const warning of warnings) {\n console.warn(warning, info.pkg, \"ApolloClient\");\n }\n\n assertInstance(\n this.cache as unknown as InMemoryCache,\n info,\n \"InMemoryCache\"\n );\n\n this.setLink(this.link);\n }\n\n setLink(newLink: ApolloLink) {\n super.setLink.call(\n this,\n ApolloLink.from([\n new ReadFromReadableStreamLink(),\n new TeeToReadableStreamLink(),\n newLink,\n ])\n );\n }\n}\n\nclass ApolloClientClientBaseImpl extends ApolloClientBase {\n constructor(options: ApolloClient.Options) {\n super(options);\n this.onQueryStarted = this.onQueryStarted.bind(this);\n\n getQueryManager(this)[wrappers] = hookWrappers;\n }\n\n private simulatedStreamingQueries = new Map<\n TransportIdentifier,\n SimulatedQueryInfo\n >();\n\n onQueryStarted({ options, id }: Extract<QueryEvent, { type: \"started\" }>) {\n const hydratedOptions = deserializeOptions(options);\n\n const [controller, stream] = getInjectableEventStream();\n\n const queryManager = getQueryManager(this);\n queryManager.fetchQuery({\n ...hydratedOptions,\n query: queryManager.transform(hydratedOptions.query),\n fetchPolicy: \"network-only\",\n context: skipDataTransport(\n readFromReadableStream(stream, {\n ...hydratedOptions.context,\n queryDeduplication: true,\n })\n ),\n });\n\n this.simulatedStreamingQueries.set(id, {\n controller,\n options: hydratedOptions,\n });\n }\n\n onQueryProgress = (event: ProgressEvent) => {\n const queryInfo = this.simulatedStreamingQueries.get(event.id);\n if (!queryInfo) return;\n\n if (\n event.type === \"error\" ||\n (event.type === \"next\" && event.value.errors)\n ) {\n /**\n * At this point we're not able to correctly serialize the error over the wire\n * so we do the next-best thing: restart the query in the browser as soon as it\n * failed on the server.\n * This matches up with what React will be doing (abort hydration and rerender)\n * See https://github.com/apollographql/apollo-client-integrations/issues/52\n */\n this.simulatedStreamingQueries.delete(event.id);\n if (process.env.REACT_ENV === \"browser\") {\n invariant.debug(\n \"Query failed on server, rerunning in browser:\",\n queryInfo.options\n );\n this.rerunSimulatedQuery(queryInfo);\n } else if (process.env.REACT_ENV === \"ssr\") {\n invariant.debug(\n \"Query failed upstream, will fail it during SSR and rerun it in the browser:\",\n queryInfo.options\n );\n queryInfo.controller.error(new Error(\"Query failed upstream.\"));\n }\n } else if (event.type === \"completed\") {\n this.simulatedStreamingQueries.delete(event.id);\n queryInfo.controller.enqueue(event);\n } else if (event.type === \"next\") {\n queryInfo.controller.enqueue(event);\n }\n };\n\n /**\n * Can be called when the stream closed unexpectedly while there might still be unresolved\n * simulated server-side queries going on.\n * Those queries will be cancelled and then re-run in the browser.\n */\n rerunSimulatedQueries = () => {\n for (const [id, queryInfo] of this.simulatedStreamingQueries) {\n this.simulatedStreamingQueries.delete(id);\n invariant.debug(\n \"streaming connection closed before server query could be fully transported, rerunning:\",\n queryInfo.options\n );\n this.rerunSimulatedQuery(queryInfo);\n }\n };\n rerunSimulatedQuery = (queryInfo: SimulatedQueryInfo) => {\n const queryManager = getQueryManager(this);\n queryManager.fetchQuery({\n ...queryInfo.options,\n fetchPolicy: \"no-cache\",\n query: queryManager.transform(queryInfo.options.query),\n context: skipDataTransport(\n teeToReadableStream(() => queryInfo.controller, {\n ...queryInfo.options.context,\n queryDeduplication: false,\n })\n ),\n });\n };\n}\n\nconst skipDataTransportKey = Symbol.for(\"apollo.dataTransport.skip\");\ninterface InternalContext {\n [skipDataTransportKey]?: boolean;\n}\n\n/**\n * Apply to a context to prevent this operation from being transported over the SSR data transport mechanism.\n * @public\n */\nexport function skipDataTransport<T extends Record<string, any>>(\n context: T\n): T & InternalContext {\n return Object.assign(context, {\n [skipDataTransportKey]: true,\n });\n}\n\nclass ApolloClientSSRImpl extends ApolloClientClientBaseImpl {\n watchQueryQueue = createBackpressuredCallback<{\n event: Extract<QueryEvent, { type: \"started\" }>;\n observable: Observable<Exclude<QueryEvent, { type: \"started\" }>>;\n }>();\n\n pushEventStream(\n options: OrigApolloClient.WatchQueryOptions<any, any>\n ): ReadableStreamDefaultCo