You are here

protected function MockGraphQLPluginTrait::resetStaticCaches in GraphQL 8.3

Reset static caches in plugin managers.

File

tests/src/Traits/MockGraphQLPluginTrait.php, line 49

Class

MockGraphQLPluginTrait
Trait for mocking GraphQL type system plugins.

Namespace

Drupal\Tests\graphql\Traits

Code

protected function resetStaticCaches() {
  $definitionsProperty = new \ReflectionProperty(DefaultPluginManager::class, 'definitions');
  $definitionsProperty
    ->setAccessible(TRUE);
  foreach ($this->graphQLPluginManagers as $manager) {
    $definitionsProperty
      ->setValue($manager, NULL);
  }
  $deriversProperty = new \ReflectionProperty(DerivativeDiscoveryDecorator::class, 'derivers');
  $deriversProperty
    ->setAccessible(TRUE);
  foreach ($this->graphqlPluginDecorators as $decorator) {
    $deriversProperty
      ->setValue($decorator, NULL);
  }
}