@apollo/client-integration-nextjs
Version:
<div align="center"> <img src="https://raw.githubusercontent.com/apollographql/apollo-client-integrations/main/banner.jpg" width="500" alt="Apollo Client + Next.js App Router" /> </div>
1 lines • 5.32 kB
Source Map (JSON)
{"version":3,"sources":["../src/index.shared.ts","../src/bundleInfo.ts","../src/ApolloNextAppProvider.ts","../src/index.ts"],"names":[],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACLA,IAAM,SAAS;AAAA,EACpB,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AACT;;;ADGA;AAAA,EACE,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,OACZ;AASA,IAAM,eAAN,cAEG,qBAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1C,OAAgB,OAAO;AACzB;AASO,IAAM,gBAAN,cAA4B,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvD,OAAgB,OAAO;AACzB;;;AE5CA,SAAS,kBAAkB;AAC3B,SAAS,gCAAgC;AACzC,SAAS,0BAA0B;AACnC,SAAS,iCAAiC;AA4CnC,IAAM,wBAAsC;AAAA,EACjD,yBAAyB;AAAA,IACvB,gBAAgB;AACd,YAAM,aAAa,WAAW,yBAAyB;AACvD,UAAI,CAAC,YAAY;AACf,YAAI,MAAqC;AAEvC,iBAAO,MAAM;AAAA,UAAC;AAAA,QAChB;AACA,cAAM,IAAI;AAAA,UACR;AAAA,QAEF;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;AACA,sBAAsB,OAAO;;;AC/D7B,SAAS,sCAAsC;AAaxC,IAAM,8BAA8B","sourcesContent":["export {\n SSRMultipartLink,\n DebounceMultipartResponsesLink,\n RemoveMultipartDirectivesLink,\n type TransportedQueryRef,\n} from \"@apollo/client-react-streaming\";\nimport { bundle } from \"./bundleInfo.js\";\nimport {\n ApolloClient as UpstreamApolloClient,\n InMemoryCache as UpstreamInMemoryCache,\n} from \"@apollo/client-react-streaming\";\n\n/**\n * A version of `ApolloClient` to be used with streaming SSR or in React Server Components.\n *\n * For more documentation, please see {@link https://www.apollographql.com/docs/react/api/core/ApolloClient | the Apollo Client API documentation}.\n *\n * @public\n */\nexport class ApolloClient<\n TCacheShape,\n> extends UpstreamApolloClient<TCacheShape> {\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\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 UpstreamInMemoryCache {\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","export const bundle = {\n pkg: \"@apollo/client-integration-nextjs\",\n client: \"ApolloClient\",\n cache: \"InMemoryCache\",\n};\n","import { useContext } from \"react\";\nimport { buildManualDataTransport } from \"@apollo/client-react-streaming/manual-transport\";\nimport { WrapApolloProvider } from \"@apollo/client-react-streaming\";\nimport { ServerInsertedHTMLContext } from \"next/navigation.js\";\nimport { bundle } from \"./bundleInfo.js\";\n\n/**\n * > This export is only available in React Client Components\n *\n * A version of `ApolloProvider` to be used with the Next.js App Router.\n *\n * As opposed to the normal `ApolloProvider`, this version does not require a `client` prop,\n * but requires a `makeClient` prop instead.\n *\n * Use this component together with `ApolloClient` and `InMemoryCache`\n * from the `\"@apollo/client-integration-nextjs\"` package\n * to make an ApolloClient instance available to your Client Component hooks in the\n * Next.js App Router.\n *\n * @example\n * `app/ApolloWrapper.jsx`\n * ```tsx\n * import { HttpLink } from \"@apollo/client\";\n * import { ApolloNextAppProvider, ApolloClient, InMemoryCache } from \"@apollo/client-integration-nextjs\";\n *\n * function makeClient() {\n * const httpLink = new HttpLink({\n * uri: \"https://example.com/api/graphql\",\n * });\n *\n * return new ApolloClient({\n * cache: new InMemoryCache(),\n * link: httpLink,\n * });\n * }\n *\n * export function ApolloWrapper({ children }: React.PropsWithChildren) {\n * return (\n * <ApolloNextAppProvider makeClient={makeClient}>\n * {children}\n * </ApolloNextAppProvider>\n * );\n * }\n * ```\n *\n * @public\n */\nexport const ApolloNextAppProvider = /*#__PURE__*/ WrapApolloProvider(\n buildManualDataTransport({\n useInsertHtml() {\n const insertHtml = useContext(ServerInsertedHTMLContext);\n if (!insertHtml) {\n if (process.env.REACT_ENV === \"browser\") {\n //Allow using the browser build of ApolloNextAppProvider outside of Next.js, e.g. for tests.\n return () => {};\n }\n throw new Error(\n \"The SSR build of ApolloNextAppProvider cannot be used outside of the Next App Router!\\n\" +\n 'If you encounter this in a test, make sure that your tests are using the browser build by adding the \"browser\" import condition to your test setup.'\n );\n }\n return insertHtml;\n },\n })\n);\nApolloNextAppProvider.info = bundle;\n","export * from \"./index.shared.js\";\nexport { ApolloNextAppProvider } from \"./ApolloNextAppProvider.js\";\nimport { resetManualSSRApolloSingletons } from \"@apollo/client-react-streaming/manual-transport\";\n/**\n * > This export is only available in React Client Components\n *\n * Resets the singleton instances created for the Apollo SSR data transport and caches.\n *\n * To be used in testing only, like\n * ```ts\n * afterEach(resetApolloClientSingletons);\n * ```\n *\n * @public\n */\nexport const resetApolloClientSingletons = resetManualSSRApolloSingletons;\n"]}