My NextJS application is build with WPGraphQl and fetching query using getServerSideProps and apollo client. at first i host in vercel and it works properly but when i deploy it to my hosting it doesn’t pull / fetch the new updated data that i have changed from wordpress dashboard unit i reset my server. I also change my endpoint URL from WordPress but Site running and showing old contents. Note: it still working fine and show updated content in vercel.
Btw, If i put following code in client query my site show updated content but in that way it takes a lot of time to load.
fetchPolicy: 'no-cache',
here is my apollo config
import {
ApolloClient,
ApolloLink,
HttpLink,
InMemoryCache,
} from "@apollo/client";
import { setContext } from '@apollo/client/link/context';
const link = ApolloLink.from([
new HttpLink({
uri: process.env.WPGRAPHQL_ENDPOINT,
}),
]);
const authLink = setContext(async (_, { headers }) => {
return {
headers: {
...headers,
authorization: process.env.WP_AUTH_REF_TOKEN ? `Bearer ${process.env.WP_AUTH_REF_TOKEN}` : '',
},
};
});
export const client = new ApolloClient({
link: authLink.concat(link),
cache: new InMemoryCache(),
})
My query:
const seoRes = await client.query({
query: getSEOstring,
// fetchPolicy: 'no-cache', /// if enabled show updated content
}
)
return{
props:{
posts: data?.posts?.edges,
seoHead: seoRes?.data?.page?.seo
}
}
}