- Issue created by @miha.wagner
- Merge request !7#3481020: Using ThunderEntitySubRequestBase breaks the general GraphQL cache → (Open) created by miha.wagner
- 🇬🇧United Kingdom alexpott 🇪🇺🌍
@miha.wagner great sleuthing. I agree this is a likely cause of a cache problem - it'd be awesome to test this somehow.
I've tried to debug this on a vanilla thunder install. I'm running \Drupal\Tests\thunder_gqls\Functional\CacheInvalidationTest::testJsonLdCacheInvalidation and I've added the code fragment below:
public function testCachingCalls(): void { $query = 'query ($path: String!) { jsonld(path: $path) }'; $variables = '{"path": "/come-drupalcon-new-orleans"}'; $response = $this->getJsonLdFromQuery($query, $variables); $this->assertEquals('Come to DrupalCon New Orleans', $response['@graph'][0]['name']); $response = $this->getJsonLdFromQuery($query, $variables); $this->assertEquals('Come to DrupalCon New Orleans', $response['@graph'][0]['name']); }
I expect there to be two subrequests.... but I only get one. What am I doing wrong? Or is this something specific to menu resolving.
- 🇸🇮Slovenia miha.wagner
This is why I should have tested on a more plain installation. So the issue is when the 'route' cache context is added. Also probably when 'url.path' is added though I did not test this.
Create a basic article on the site. Then this request can be used:
{"query":"query MyQuery {\n breadcrumb(\n path: \"<path-to-the-article>\"\n ) {\n title\n url\n }\n}\n","variables":null,"operationName":"MyQuery"}
The breadcrumbs builder do add the 'route' cache context to the response. So triggering this will always invoke the sub-request, though it should only trigger it once.