Skip to content

Commit

Permalink
fix(graphql): temporary fix for GET-based GraphQL queries
Browse files Browse the repository at this point in the history
  • Loading branch information
pmelab committed Apr 15, 2023
1 parent d1e1096 commit 255ae41
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
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 }
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',
];
}
}

0 comments on commit 255ae41

Please sign in to comment.