Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions apollo-router/src/plugins/response_cache/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,10 +1267,7 @@ async fn cache_lookup_root(
Ok(value) => {
if value.control.can_use() {
let control = value.control.clone();
request
.context
.extensions()
.with_lock(|lock| lock.insert(control));
update_cache_control(&request.context, &control);
if debug {
let root_operation_fields: Vec<String> = request
.executable_document
Expand Down Expand Up @@ -1632,7 +1629,6 @@ fn update_cache_control(context: &Context, cache_control: &CacheControl) {
if let Some(c) = lock.get_mut::<CacheControl>() {
*c = c.merge(cache_control);
} else {
//FIXME: race condition. We need an Entry API for private entries
lock.insert(cache_control.clone());
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
source: apollo-router/src/plugins/response_cache/tests.rs
expression: cache_keys
---
[
{
"key": "private_and_public-version:1.0:subgraph:orga:type:Query:hash:d72fc5bd9cc1994bdd5bee5d0f62417a27385b44300212a56d332be2e064798e:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c:03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4",
"invalidationKeys": [],
"kind": {
"rootFields": [
"orga"
]
},
"subgraphName": "orga",
"subgraphRequest": {
"query": "{ orga(id: \"2\") { name } }"
},
"status": "cached",
"cacheControl": {
"created": 0,
"maxAge": 86400,
"private": true
},
"data": {
"data": {
"orga": {
"name": "test_orga"
}
}
}
},
{
"key": "private_and_public-version:1.0:subgraph:user:type:Query:hash:26ab4118dbabffe5dfbef4462513caa8b6c8941363cf2eafa874bf1d47a3c468:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c",
"invalidationKeys": [
"currentUser"
],
"kind": {
"rootFields": [
"currentUser"
]
},
"subgraphName": "user",
"subgraphRequest": {
"query": "{ currentUser { activeOrganization { __typename id } } }"
},
"status": "cached",
"cacheControl": {
"created": 0,
"maxAge": 86400,
"public": true
},
"data": {
"data": {
"currentUser": {
"activeOrganization": {
"__typename": "Organization",
"id": "1"
}
}
}
}
},
{
"key": "version:1.0:subgraph:orga:type:Organization:entity:bcc0a4a9f8c595510c0ff8849bc36b402ac3f52506392d67107c623528ff11f4:representation::hash:a7ccf1576978c6598f6d10d8855fc683f71242533dc6d5a706743bd9bbfa554c:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c:03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4",
"invalidationKeys": [
"organization",
"organization-1"
],
"kind": {
"typename": "Organization",
"entityKey": {
"id": "1"
}
},
"subgraphName": "orga",
"subgraphRequest": {
"query": "query($representations: [_Any!]!) { _entities(representations: $representations) { ... on Organization { creatorUser { __typename id } } } }",
"variables": {
"representations": []
}
},
"status": "cached",
"cacheControl": {
"created": 0,
"maxAge": 86400,
"private": true
},
"data": {
"data": {
"creatorUser": {
"__typename": "User",
"id": 2
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
source: apollo-router/src/plugins/response_cache/tests.rs
expression: cache_keys
---
[
{
"key": "version:1.0:subgraph:orga:type:Query:hash:d72fc5bd9cc1994bdd5bee5d0f62417a27385b44300212a56d332be2e064798e:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c:f8638b979b2f4f793ddb6dbd197e0ee25a7a6ea32b0ae22f5e3c5d119d839e75",
"invalidationKeys": [],
"kind": {
"rootFields": [
"orga"
]
},
"subgraphName": "orga",
"subgraphRequest": {
"query": "{ orga(id: \"2\") { name } }"
},
"status": "new",
"cacheControl": {
"created": 0,
"maxAge": 86400,
"private": true
},
"data": {
"data": {
"orga": {
"name": "test_orga"
}
}
}
},
{
"key": "private_and_public-version:1.0:subgraph:user:type:Query:hash:26ab4118dbabffe5dfbef4462513caa8b6c8941363cf2eafa874bf1d47a3c468:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c",
"invalidationKeys": [
"currentUser"
],
"kind": {
"rootFields": [
"currentUser"
]
},
"subgraphName": "user",
"subgraphRequest": {
"query": "{ currentUser { activeOrganization { __typename id } } }"
},
"status": "cached",
"cacheControl": {
"created": 0,
"maxAge": 86400,
"public": true
},
"data": {
"data": {
"currentUser": {
"activeOrganization": {
"__typename": "Organization",
"id": "1"
}
}
}
}
},
{
"key": "version:1.0:subgraph:orga:type:Organization:entity:bcc0a4a9f8c595510c0ff8849bc36b402ac3f52506392d67107c623528ff11f4:representation::hash:a7ccf1576978c6598f6d10d8855fc683f71242533dc6d5a706743bd9bbfa554c:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c:f8638b979b2f4f793ddb6dbd197e0ee25a7a6ea32b0ae22f5e3c5d119d839e75",
"invalidationKeys": [
"organization",
"organization-1"
],
"kind": {
"typename": "Organization",
"entityKey": {
"id": "1"
}
},
"subgraphName": "orga",
"subgraphRequest": {
"query": "query($representations: [_Any!]!) { _entities(representations: $representations) { ... on Organization { creatorUser { __typename id } } } }",
"variables": {
"representations": [
{
"id": "1",
"__typename": "Organization"
}
]
}
},
"status": "new",
"cacheControl": {
"created": 0,
"maxAge": 86400,
"private": true
},
"data": {
"data": {
"creatorUser": {
"__typename": "User",
"id": 2
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
source: apollo-router/src/plugins/response_cache/tests.rs
expression: cache_keys
---
[
{
"key": "version:1.0:subgraph:orga:type:Query:hash:d72fc5bd9cc1994bdd5bee5d0f62417a27385b44300212a56d332be2e064798e:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c:03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4",
"invalidationKeys": [],
"kind": {
"rootFields": [
"orga"
]
},
"subgraphName": "orga",
"subgraphRequest": {
"query": "{ orga(id: \"2\") { name } }"
},
"status": "new",
"cacheControl": {
"created": 0,
"maxAge": 86400,
"private": true
},
"data": {
"data": {
"orga": {
"name": "test_orga"
}
}
}
},
{
"key": "version:1.0:subgraph:user:type:Query:hash:26ab4118dbabffe5dfbef4462513caa8b6c8941363cf2eafa874bf1d47a3c468:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c",
"invalidationKeys": [
"currentUser"
],
"kind": {
"rootFields": [
"currentUser"
]
},
"subgraphName": "user",
"subgraphRequest": {
"query": "{ currentUser { activeOrganization { __typename id } } }"
},
"status": "new",
"cacheControl": {
"created": 0,
"maxAge": 86400,
"public": true
},
"data": {
"data": {
"currentUser": {
"activeOrganization": {
"__typename": "Organization",
"id": "1"
}
}
}
}
},
{
"key": "version:1.0:subgraph:orga:type:Organization:entity:bcc0a4a9f8c595510c0ff8849bc36b402ac3f52506392d67107c623528ff11f4:representation::hash:a7ccf1576978c6598f6d10d8855fc683f71242533dc6d5a706743bd9bbfa554c:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c:03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4",
"invalidationKeys": [
"organization",
"organization-1"
],
"kind": {
"typename": "Organization",
"entityKey": {
"id": "1"
}
},
"subgraphName": "orga",
"subgraphRequest": {
"query": "query($representations: [_Any!]!) { _entities(representations: $representations) { ... on Organization { creatorUser { __typename id } } } }",
"variables": {
"representations": [
{
"id": "1",
"__typename": "Organization"
}
]
}
},
"status": "new",
"cacheControl": {
"created": 0,
"maxAge": 86400,
"private": true
},
"data": {
"data": {
"creatorUser": {
"__typename": "User",
"id": 2
}
}
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expression: cache_keys
---
[
{
"key": "private-version:1.0:subgraph:user:type:Query:hash:26ab4118dbabffe5dfbef4462513caa8b6c8941363cf2eafa874bf1d47a3c468:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c:03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4",
"key": "private_only-version:1.0:subgraph:user:type:Query:hash:26ab4118dbabffe5dfbef4462513caa8b6c8941363cf2eafa874bf1d47a3c468:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c:03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4",
"invalidationKeys": [
"currentUser"
],
Expand Down
Loading