GraphQL cache issue

Hi,

I might be doing something wrong but I'm having problems with stale data when using the graphql endpoint via apollo using apollo-link-prismic

Does it take into account the prismic-ref when caching responses? Or is there something I'm missing to make it do this? I've tried setting the fetchPolicy on useQuery to 'no-cache' but it's still using stale data from the cache.

Cheers,
Paul

3 Likes

Hmm, I installed the Apollo chrome inspector tool and when I use 'no-cache', it shows the Apollo cache as empty, so maybe it's the browser cache that's causing a problem instead? Any way round this?

Hi there,

Welcome to the Prismic community.

A quick question, have you tied open your page in an incognito (Private browser session)?

Fares

Thanks for the welcome :slight_smile:

Yeah, it gets the updates in an incognito window, but then if I make more updates then these aren't shown. It also works if I tick 'disable cache' in chrome inspector.

(I get the same problems in react native android app)

Can you send us a screenshot of your configurations with masking the token if you have any? such:

Screenshot 2022-02-09 at 16.35.34

const fragmentMatcher = new IntrospectionFragmentMatcher({
    introspectionQueryResultData: fragmentTypes,
})

export const apolloClient = new ApolloClient({
    link: PrismicLink({
        uri: 'https://mossyearth.cdn.prismic.io/graphql',
        accessToken: process.env.REACT_APP_PRISMIC_ACCESS_TOKEN,
    }),
    connectToDevTools: true,
    cache: new InMemoryCache({ fragmentMatcher }),
})

I've tried both with and without the fragmentMatcher

1 Like

Can you try without

If I do that it still calls the link with cdn in... I believe in the apollo prismic plugin enforces using that url? https://github.com/prismicio/apollo-link-prismic/blob/f3577d09cb3e1524b1e74cebd10839ef072d73b1/src/index.js

1 Like

Oh and for 'size' of response in chrome inspector, it says 'disk cache'

Hey @Fares, did you have any luck with this?

Cheers,
Paul

This issue suddenly began for me, too, a week or two ago. Maybe a little longer than that, even. Would love an update or guidance on how to resolve.

Thanks, @paul4 @secure; I will check our dev team, and get back to you.

I'm a Paul as well, maybe it just doesn't like Pauls? :slight_smile:

Glad it's not just us though, and that it's a recent thing, we've only recently implemented it and so we weren't 100% sure whether we were just mis-remembering that it worked correctly when we first implemented it.

3 Likes

Hi @Fares,

Any update on this? Not being able to get the latest updates for content is causing us quite an issue.

Cheers,
Paul

Hi,

I have followed up again with our dev team, and I will let you know if we get any updates, it seems for me the issue comes from the browser cache, do you agree?

yeah I believe so, but it seems the problem only started recently, and so likely a change on the Prismic end.

Cheers,
Paul

And it's across different browsers

Hi, We are releasing soon an update of apollo-link-prismic and we will check this issue at the same time.

2 Likes

Hi @Fares, I don't suppose you have a rough estimate of how long it'll be? At the moment this issue is stopping us releasing our app, as it doesn't get updated content.

Cheers,
Paul

Hi, I'm checking with our dev team to see if I can get an ETA, and I will get back to you.

1 Like