apollo-client-integrations: `NextSSRInMemoryCache` is not exported by `@apollo/experimental-nextjs-app-support/ssr`

In node_modules/.pnpm/@apollo+experimental-nextjs-app-support@0.9.1_@apollo+client@3.9.10_next@14.1.4_react@18.2.0/node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/index.ssr.js

import { useContext } from 'react';
import { buildManualDataTransport } from '@apollo/client-react-streaming/manual-transport';
export { resetManualSSRApolloSingletons as resetNextSSRApolloSingletons } from '@apollo/client-react-streaming/manual-transport';
import { WrapApolloProvider, ApolloClient } from '@apollo/client-react-streaming';
export { DebounceMultipartResponsesLink, InMemoryCache as NextSSRInMemoryCache, RemoveMultipartDirectivesLink, SSRMultipartLink } from '@apollo/client-react-streaming';
import { ServerInsertedHTMLContext } from 'next/navigation.js';
export { useBackgroundQuery, useFragment, useQuery, useReadQuery, useSuspenseQuery } from '@apollo/client/index.js';

// src/ApolloNextAppProvider.ts

// src/bundleInfo.ts
var bundle = {
  pkg: "@apollo/experimental-nextjs-app-support/ssr",
  client: "NextSSRApolloClient",
  cache: "NextSSRInMemoryCache"
};

// src/ApolloNextAppProvider.ts
var ApolloNextAppProvider = /* @__PURE__ */ WrapApolloProvider(
  buildManualDataTransport({
    useInsertHtml() {
      const insertHtml = useContext(ServerInsertedHTMLContext);
      if (!insertHtml) {
        throw new Error(
          "ApolloNextAppProvider cannot be used outside of the Next App Router!"
        );
      }
      return insertHtml;
    }
  })
);
ApolloNextAppProvider.info = bundle;
var NextSSRApolloClient = class extends ApolloClient {
  /**
   * Information about the current package and it's export names, for use in error messages.
   *
   * @internal
   */
  static info = bundle;
};

export { ApolloNextAppProvider, NextSSRApolloClient };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.ssr.js.map

NextSSRInMemoryCache is not exported.

I am using version 0.9.1

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 21 (12 by maintainers)

Commits related to this issue

Most upvoted comments

I found the issue is that in version 0.9.0

the usage is changed, some exports is moved to another new package.

To fix the issue, simply change the import from:

import {
  NextSSRApolloClient,
  NextSSRInMemoryCache,
  SSRMultipartLink,
} from "@apollo/experimental-nextjs-app-support/ssr";

to:

import {
  ApolloClient,
  InMemoryCache,
  SSRMultipartLink,
} from '@apollo/client-react-streaming'

I also created a PR #269 to update the documents

The same issue occurs when importing registerApolloClient import { registerApolloClient } from "@apollo/experimental-nextjs-app-support/rsc";

just copy pasted the example from the github readme export const { getClient } = registerApolloClient(() => { return new ApolloClient({ ... }) }

So where’s the place I’m supposed to fetch initial data that might change later? […] Is this what https://github.com/apollographql/apollo-client-nextjs/pull/258 is there for?

Yup. That, or you just use useSuspenseQuery in a client component, which will fetch the data in SSR, not RSC - but only on the first request, not on further navigation. (That’s what you’ll be using RSC+PreloadQuery from #258 for)

Actually I am upgrading from 0.8.0 to 0.9.1 it became broken

NextSSRApolloClient is also not usable.

Error: __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f40$apollo$2b$experimental$2d$nextjs$2d$app$2d$support$40$0$2e$9$2e$1_$40$apollo$2b$client$40$3$2e$9$2e$10_next$40$14$2e$1$2e$4_react$40$18$2e$2$2e$0$2f$node_modules$2f40$apollo$2f$experimental$2d$nextjs$2d$app$2d$support$2f$dist$2f$ssr$2f$index$2e$rsc$2e$js__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__$7b$exports$7d$__.NextSSRApolloClient is not a constructor

I tried to import import * as test from '@apollo/experimental-nextjs-app-support/ssr'

and the result:

Object [Module] {
 DebounceMultipartResponsesLink: [Getter],
 RemoveMultipartDirectivesLink: [Getter],
 SSRMultipartLink: [Getter]
 }