apollographql / apollographql/federation
Cache control hints doesn't work on extended types on federated schemas
- Dominant language
- TypeScript
- Stars
- 725
- Forks
- 276
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 1
Description
### Packages
```
{
"@apollo/federation": "^0.11.0",
"apollo-server": "^2.9.9",
"apollo-server-plugin-response-cache": "^0.3.5"
}
```
### Issue
It seems like cache control hints doesn't work on extended types on federated schemas
Having these schemas in two different federated services
```graphql
# This is defined on the users service
type User @key(fields: "id") {
id: ID!
username: String
}
extend type Query {
me: User @cacheControl(maxAge: 60)
}
```
```graphql
# This is defined on the organizations service
type Organization @key(fields: "id") {
id: ID!
name: String
}
extend type User @key(fields: "id") {
id: ID! @external
currentOrg: Organization @cacheControl(maxAge: 60)
}
extend type Query {
currentOrg: Organization
}
```
and running this query
```graphql
query {
me {
id
username
currentOrg {
id
name
}
}
}
```
results on the `me` query response being cached but not the one from `me.currentOrg`.
I also tried setting `info.cacheControl.setCacheHint({ maxAge: 60 })` on both resolvers and the result is the same.
### Expected behavior
The response from `me` and `me.CurrentOrg` are cached
### Actual behavior
Only the response from `me` is cached
### Steps to reproduce
I created a repo that reproduces this behavior here https://github.com/gnkz/apollo-federation-cache
Contributor guide
Research direction
Start by running the reproduction repository at https://github.com/gnkz/apollo-federation with the listed @apollo/federation, apollo-server, and apollo-server-plugin-response-cache versions. Compare cache-control behavior for me and me.currentOrg, including resolver hints; done when both responses are cached across the federated schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100