Cache results not changing even with fetch policy set to network-only or no-cache?
I'm having an issue using this library that whenever I change something in my backend, the next js app does not update with the new results(when refreshing the page) even if the fetch policy is network-only o no-cache, any ideas why this is happening, or is there some documentation on how to accomplish that.
import {ssrGetRanking, PageGetRankingComp} from 'generated/page'
import {GetServerSidePropsContext} from 'next'
import React from 'react'
import {withApollo} from 'withApollo'
const RankingPage: PageGetRankingComp = ({data, error}) => {
// Comp logic goes here
}
export async function getServerSideProps(ctx: GetServerSidePropsContext) {
return await ssrGetRanking.getServerPage({fetchPolicy: 'network-only'}, ctx)
}
export default withApollo(ssrGetRanking.withPage(() => ({}))(RankingPage))
I also try to add the fetch policy in the HOC wrap but then I notice that the component was having a delay with the data values because it displays undefined and after that the data is valid.
import {ssrGetRanking, PageGetRankingComp} from 'generated/page'
import {GetServerSidePropsContext} from 'next'
import React from 'react'
import {withApollo} from 'withApollo'
const RankingPage: PageGetRankingComp = ({data, error}) => {
// Comp logic goes here
}
export async function getServerSideProps(ctx: GetServerSidePropsContext) {
return await ssrGetRanking.getServerPage({fetchPolicy: 'network-only'}, ctx)
}
export default withApollo(
ssrGetRanking.withPage(() => ({fetchPolicy: 'network-only'}))(RankingPage),
)
hi,
Not sure what's the cause of the issue without looking at the full example. This plugin doesn't affect the apollo cache, it only reads it.
the ApolloProvider should always create a new instance of the apolloClient when running on the server (on the client it can be a singleton).
You can see an example https://github.com/correttojs/graphql-codegen-apollo-next-ssr/blob/main/example/src/withApollo.tsx#L11