-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(graphql): temporary fix for GET-based GraphQL queries
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...omposer/amazeelabs/silverback_graphql_persisted/silverback_graphql_persisted.services.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
services: | ||
fix_graphql_caching_subscriber: | ||
class: Drupal\silverback_graphql_persisted\EventSubscriber\FixGraphQLCachingSubscriber | ||
tags: | ||
- { name: event_subscriber } |
27 changes: 27 additions & 0 deletions
27
...azeelabs/silverback_graphql_persisted/src/EventSubscriber/FixGraphQLCachingSubscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
namespace Drupal\silverback_graphql_persisted\EventSubscriber; | ||
|
||
use Drupal\graphql\Event\OperationEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
/** | ||
* Fix GraphQL caching when internal page cache is active: | ||
* | ||
* TODO: | ||
* Can be removed when https://github.com/drupal-graphql/graphql/pull/1317 is | ||
* resolved. | ||
*/ | ||
class FixGraphQLCachingSubscriber implements EventSubscriberInterface { | ||
|
||
public function onBeforeOperation(OperationEvent $event): void { | ||
$event->getContext()->addCacheContexts( | ||
['url.query_args:variables', 'url.query_args:extensions'] | ||
); | ||
} | ||
|
||
public static function getSubscribedEvents() { | ||
return [ | ||
OperationEvent::GRAPHQL_OPERATION_BEFORE => 'onBeforeOperation', | ||
]; | ||
} | ||
} |