File tree Expand file tree Collapse file tree
modules/graphql_core/src/Plugin/Deriver/Fields Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77use Drupal \Core \Plugin \Discovery \ContainerDeriverInterface ;
88use Drupal \graphql \Utility \StringHelper ;
99use Symfony \Component \DependencyInjection \ContainerInterface ;
10+ use Drupal \Core \Cache \CacheableDependencyInterface ;
1011
1112class ContextDeriver extends DeriverBase implements ContainerDeriverInterface {
1213
@@ -44,7 +45,13 @@ public function getDerivativeDefinitions($basePluginDefinition) {
4445 'name ' => StringHelper::propCase ($ id , 'context ' ),
4546 'context_id ' => $ id ,
4647 'type ' => $ context ->getContextDefinition ()->getDataType (),
47- ] + $ basePluginDefinition ;
48+ ];
49+ // Add cache contexts, if available
50+ if ($ context instanceof CacheableDependencyInterface) {
51+ $ this ->derivatives [$ id ]['response_cache_contexts ' ] = $ context ->getCacheContexts ();
52+ }
53+ // Add default base
54+ $ this ->derivatives [$ id ] += $ basePluginDefinition ;
4855 }
4956 }
5057
You can’t perform that action at this time.
0 commit comments