apollo-server
apollo-server copied to clipboard
apollo-datasource-rest caching everything
apollo-datasource-rest
has a HTTPCache
that probably works fine, but it is never invoked because RESTDataSource
caches the promise itself, the first time it is called (for GET requests).
This seems to defeat the purpose of having HTTPCache
altogether, but looking at the Git history, a good deal of work was put into this memoization, so maybe there is a reason for it?
https://github.com/apollographql/apollo-server/blob/f25784d51130bbb9014b727e2f231e5a737f4a50/packages/apollo-datasource-rest/src/RESTDataSource.ts#L270
I guess this is why 408 timeout errors for GET requests are cached 🤔
I ran into this issue as well, and the cause turned out to be me not instantiating a new datasource for every request. More detail can be found in this comment, thought I share it here.
While HTTPCache is responsible for long-term caching based on HTTP semantics and TTL, memoization makes sure we don't perform the same REST call twice within the same GraphQL request.
Hi there, I just posted a detailed description of the problem. Hope you find it useful until/if the issue gets fixed