Skip to content
Open
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
12 changes: 10 additions & 2 deletions src/EventSubscriber/FixGraphQLCachingSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Drupal\silverback_graphql_persisted\EventSubscriber;

use Drupal\graphql\Event\OperationEvent;
Expand All @@ -7,21 +8,28 @@
/**
* Fix GraphQL caching when internal page cache is active:
*
* TODO:
* @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']
['url.query_args:queryId', 'url.query_args:variables', 'url.query_args:extensions']
);
}

/**
*
*/
public static function getSubscribedEvents() {
return [
OperationEvent::GRAPHQL_OPERATION_BEFORE => 'onBeforeOperation',
];
}

}