1
votes

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.

1
I should have known that I was doing something wrong. I'm using NGX datatables and was loading data with observable which wasn't updating the table data. I'm still working on getting it to work but it wasn't apollo client. It's working fine. - cyberthreat
Ultimately my problem was with the way angular handles events. I was calling a function in component B from component A. Even though I was updating the underlying data for the datatable, the push event wasn't occurring. I still don't understand why, but moving the datatable into the same component that generated the original event(Component A) solved my problem. - cyberthreat

1 Answers

2
votes

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

Try using network-only instead of no-cache