apollographql / apollographql/federation
Caching on gateway LocalGraphQLDataSource level does not seem to work
- Dominant language
- TypeScript
- Stars
- 725
- Forks
- 276
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 1
Description
### Issue Description
I am running into an issue where the apollo supergraph's caching does not work, but the underlying supgraphs just work fine.
When executing
```
query a {
foo
}
```
I get response header `cache-control: no-store`
When executing
```
query b {
products {
name
}
}
```
I get response header `cache-control: max-age=500, public`
When executing
```
query c {
foo
products {
name
}
}
```
I get response header `cache-control: max-age=500, public`
Problem 1: I cannot seem to make the cache work for query foo
Problem 2: When querying foo with any other cached subgraph query, it just applies the cacheControl of that query to the whole response, but IMO it should compute the correct restrictive one.
### Link to Reproduction
https://codesandbox.io/p/devbox/headless-cherry-2xpp5d
### Reproduction Steps
```
query c {
foo
}
```
Contributor guide
Research direction
Start by running the linked CodeSandbox reproduction and its three queries, comparing the cache-control headers for foo, products, and their combination. Trace the gateway's LocalGraphQLDataSource caching path to determine why foo is no-store and why mixed responses do not use the restrictive policy. Done means the reproduction shows appropriate caching for foo and the combined query reports the correct restrictive cache-control header.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100