From 255ae419d5ea0ab29bb96a7a7b5256a893a01be2 Mon Sep 17 00:00:00 2001 From: Philipp Melab Date: Sat, 15 Apr 2023 08:00:34 +0200 Subject: [PATCH] fix(graphql): temporary fix for GET-based GraphQL queries https://github.com/drupal-graphql/graphql/pull/1317 --- .../silverback_graphql_persisted.services.yml | 5 ++++ .../FixGraphQLCachingSubscriber.php | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 packages/composer/amazeelabs/silverback_graphql_persisted/silverback_graphql_persisted.services.yml create mode 100644 packages/composer/amazeelabs/silverback_graphql_persisted/src/EventSubscriber/FixGraphQLCachingSubscriber.php diff --git a/packages/composer/amazeelabs/silverback_graphql_persisted/silverback_graphql_persisted.services.yml b/packages/composer/amazeelabs/silverback_graphql_persisted/silverback_graphql_persisted.services.yml new file mode 100644 index 000000000..f146f7374 --- /dev/null +++ b/packages/composer/amazeelabs/silverback_graphql_persisted/silverback_graphql_persisted.services.yml @@ -0,0 +1,5 @@ +services: + fix_graphql_caching_subscriber: + class: Drupal\silverback_graphql_persisted\EventSubscriber\FixGraphQLCachingSubscriber + tags: + - { name: event_subscriber } \ No newline at end of file diff --git a/packages/composer/amazeelabs/silverback_graphql_persisted/src/EventSubscriber/FixGraphQLCachingSubscriber.php b/packages/composer/amazeelabs/silverback_graphql_persisted/src/EventSubscriber/FixGraphQLCachingSubscriber.php new file mode 100644 index 000000000..12f5adfb7 --- /dev/null +++ b/packages/composer/amazeelabs/silverback_graphql_persisted/src/EventSubscriber/FixGraphQLCachingSubscriber.php @@ -0,0 +1,27 @@ +getContext()->addCacheContexts( + ['url.query_args:variables', 'url.query_args:extensions'] + ); + } + + public static function getSubscribedEvents() { + return [ + OperationEvent::GRAPHQL_OPERATION_BEFORE => 'onBeforeOperation', + ]; + } +}