Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(graphql): temporary fix for GET-based GraphQL queries #1337

Merged
merged 1 commit into from
Apr 15, 2023
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
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',
];
}
}