So we have this problem with Apollo client. Our stack if following: PayloadCMS graphQL API and Next.js 14 with Apollo client.
The problem is following when data are changed on the PayloadCMS, the Next website data are not updated. Sometimes force reload fixes the problem (which is not solution), and even stranger for me is that only sometimes.
I feel like we tried all possible configuration that we could to fix it. Still without success. The best solution would be disable caching permanently and always fetch newest data from server.
Apollo client config:
import { HttpLink } from "@apollo/client";
import {
registerApolloClient,
ApolloClient,
InMemoryCache,
} from "@apollo/experimental-nextjs-app-support";
export const { getClient } = registerApolloClient(() => {
return new ApolloClient({
link: new HttpLink({
uri: `${process.env.NEXT_PUBLIC_ADMIN_BASE_URI}/api/graphql`,
}),
defaultOptions: {
query: {
fetchPolicy: "network-only",
},
},
ssrMode: true,
ssrForceFetchDelay: 1,
cache: new InMemoryCache({
resultCaching: false,
}),
});
});
Fetching the data using Postman is always fine, so I assumed the problem is on the client side.