"cache-and-network" fails silently on a query that works with all other fetch policies

const response = await apollo_client_instance.query({ query: my_query, variables: { request: my_request }, fetchPolicy: fetch_policy }, true);
console.log("response:", response);

Using the code above I can observe the request going out and a response being logged for all the cache policies other than “cache-and-network”. No errors thrown, just disappears into a black hole. I’d really like to provide a snappy response by using the cached data (and have this working with the “cache-first” policy) but I also need to go to the network as our users can edit the data being pulled in by this request using a different tool. Is this a known bug? I couldn’t seem to find any matching open issues. Any tips or assistance here much appreciated.

James

Even curiouser is that I can literally set the fetchPolicy to ANY random string and it doesn’t error. Looks like it just falls back to a default policy. But if I set it to “cache-and-network” then boom everything stops working. I’ve tried breaking on caught errors and nothing, there’s no sign at all what’s going on here.

Also worth noting that the “cache-and-network” fetchPolicy works perfectly well when set while using the react hook useLazyQuery, but not when via the query method of an apollo client instance.

In case it helps, these are my relevant dependency versions

"@apollo/client": "3.5.10"
"graphql": "16.0.1"

Did I fail to explain this well or did I miss something else that might have helped to get a response?

@atomless it looks like you’re using ApolloClient.query for this - the query method doesn’t support cache-and-network. If you’re running in development mode you should see a warning about this in your browser console. See: apollo-client/ApolloClient.ts at 5a60ac22fe4ed538a3cfb1cf64298360cd129116 · apollographql/apollo-client · GitHub

invariant(
  (options.fetchPolicy as WatchQueryFetchPolicy) !== 'cache-and-network',
  'The cache-and-network fetchPolicy does not work with client.query, because ' +
  'client.query can only return a single result. Please use client.watchQuery ' +
  'to receive multiple results from the cache and the network, or consider ' +
  'using a different fetchPolicy, such as cache-first or network-only.'
);