66use Drupal \Core \Cache \CacheBackendInterface ;
77use Drupal \Core \Extension \ModuleHandlerInterface ;
88use Drupal \Core \Plugin \DefaultPluginManager ;
9+ use Drupal \graphql \GraphQLLanguageContext ;
910
1011class FieldPluginManager extends DefaultPluginManager {
1112
@@ -16,6 +17,15 @@ class FieldPluginManager extends DefaultPluginManager {
1617 */
1718 protected $ instances ;
1819
20+ /**
21+ * The language context.
22+ *
23+ * Will be passed on to all plugin instances.
24+ *
25+ * @var \Drupal\graphql\GraphQLLanguageContext
26+ */
27+ protected $ languageContext ;
28+
1929 /**
2030 * FieldPluginManager constructor.
2131 *
@@ -28,6 +38,8 @@ class FieldPluginManager extends DefaultPluginManager {
2838 * The module handler.
2939 * @param \Drupal\Core\Cache\CacheBackendInterface $cacheBackend
3040 * The cache backend.
41+ * @param \Drupal\graphql\GraphQLLanguageContext $languageContext
42+ * The language context.
3143 * @param string|null $pluginInterface
3244 * The interface each plugin should implement.
3345 * @param string $pluginAnnotationName
@@ -40,10 +52,12 @@ public function __construct(
4052 \Traversable $ namespaces ,
4153 ModuleHandlerInterface $ moduleHandler ,
4254 CacheBackendInterface $ cacheBackend ,
55+ GraphQLLanguageContext $ languageContext ,
4356 $ pluginInterface ,
4457 $ pluginAnnotationName ,
4558 array $ config
4659 ) {
60+
4761 parent ::__construct (
4862 $ pluginSubdirectory ,
4963 $ namespaces ,
@@ -52,11 +66,22 @@ public function __construct(
5266 $ pluginAnnotationName
5367 );
5468
69+ $ this ->languageContext = $ languageContext ;
5570 $ this ->alterInfo ('graphql_fields ' );
5671 $ this ->useCaches (empty ($ config ['development ' ]));
5772 $ this ->setCacheBackend ($ cacheBackend , 'fields ' , ['graphql ' ]);
5873 }
5974
75+ /**
76+ * {@inheritdoc}
77+ */
78+ public function createInstance ($ plugin_id , array $ configuration = []) {
79+ /** @var \Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase $plugin */
80+ $ plugin = parent ::createInstance ($ plugin_id , $ configuration );
81+ $ plugin ->setLanguageContext ($ this ->languageContext );
82+ return $ plugin ;
83+ }
84+
6085 /**
6186 * {@inheritdoc}
6287 */
0 commit comments