Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apollo angular client always using cache

I'm using apollo angular client with the InMemoryCache. I have some watchQuery's for which I want to disable caching. I've setup my client as follows:

link: httpLink.create({uri}),
    cache: new InMemoryCache(),
    ssrMode: false,
    ssrForceFetchDelay:0,
    defaultOptions: {
      watchQuery: {
        fetchPolicy: 'no-cache',
        errorPolicy: 'ignore',
      },
      query: {
        fetchPolicy: 'no-cache',
        errorPolicy: 'all',
      },
    }

and my watchQuery looks like this:

return this.apollo.watchQuery<TestAssetListQuery>({
        query: gql`
          query {
              testAssetList {
                name,
                path,
                size
              }
          }
        `,
        fetchPolicy: "no-cache",
      }).valueChanges;

Yet, every subsequent query is pulled from cache.

I'd appreciate any advice on how to force apollo not to cache my queries.

like image 257
cyberthreat Avatar asked Sep 02 '25 11:09

cyberthreat


1 Answers

Since I have not enough reputation to comment. I will try to post it.

Try using network-only instead of no-cache

like image 80
Anuj Avatar answered Sep 04 '25 04:09

Anuj