Skip to content

Commit ac9fe52

Browse files
author
Luis
committed
Drupal 10 compatility fix bugs
1 parent a3a1ec5 commit ac9fe52

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

modules/graphql_core/src/Plugin/GraphQL/Fields/EntityFieldBase.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
use Drupal\Component\Render\MarkupInterface;
66
use Drupal\Core\Cache\CacheableDependencyInterface;
7-
use Drupal\Core\Cache\CacheableMetadata;
87
use Drupal\Core\Entity\ContentEntityInterface;
9-
use Drupal\Core\Entity\Entity;
10-
use Drupal\Core\Entity\EntityInterface;
118
use Drupal\Core\Field\FieldItemInterface;
129
use Drupal\graphql\GraphQL\Execution\ResolveContext;
1310
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;

modules/graphql_core/tests/src/Kernel/Blocks/BlockTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
77
use Drupal\Tests\block\Traits\BlockCreationTrait;
88
use Drupal\Tests\graphql_core\Kernel\GraphQLCoreTestBase;
9-
use Symfony\Component\HttpFoundation\Session\Session;
109

1110
/**
1211
* Test block retrieval via GraphQL.
@@ -37,11 +36,6 @@ class BlockTest extends GraphQLCoreTestBase {
3736
protected function setUp(): void {
3837
parent::setUp();
3938

40-
$request = $this->container->get('request_stack')->getCurrentRequest();
41-
42-
$session = new Session();
43-
$request->setSession($session);
44-
4539
/** @var \Drupal\Core\Extension\ThemeInstallerInterface $themeInstaller */
4640
$themeInstaller = $this->container->get('theme_installer');
4741
$themeInstaller->install(['stark']);
@@ -85,7 +79,7 @@ public function testStaticBlocks() {
8579
'block_content:1',
8680
// @todo Check metatags. Is the config metatag required?
8781
'config:block.block.stark_powered',
88-
])->setCacheMaxAge(0);
82+
]);
8983

9084
$this->assertResults($query, [], [
9185
'route' => [

modules/graphql_core/tests/src/Kernel/GraphQLCoreTestBase.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Drupal\Tests\graphql_core\Kernel;
44

55
use Drupal\Tests\graphql\Kernel\GraphQLTestBase;
6+
use Symfony\Component\HttpFoundation\Session\Session;
67

78
/**
89
* Test base for drupal core graphql functionality.
@@ -27,6 +28,11 @@ protected function setUp(): void {
2728
$this->container->get('module_handler')->loadInclude('user', 'install');
2829
$this->installEntitySchema('user');
2930
user_install();
31+
32+
// Init session.
33+
$request = $this->container->get('request_stack')->getCurrentRequest();
34+
$session = new Session();
35+
$request->setSession($session);
3036
}
3137

3238
}

src/GraphQL/Execution/QueryProcessor.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
use GraphQL\Validator\ValidationContext;
3030
use Symfony\Component\HttpFoundation\RequestStack;
3131

32+
/**
33+
* Query processor class.
34+
*/
3235
class QueryProcessor {
3336

3437
/**
@@ -199,7 +202,7 @@ protected function executeOperation(PromiseAdapter $adapter, ServerConfig $confi
199202
}
200203

201204
// Only queries can be cached (mutations and subscriptions can't).
202-
if ($type === 'query') {
205+
if ($type->operation === 'query') {
203206
return $this->executeCacheableOperation($adapter, $config, $params, $document, !$persisted);
204207
}
205208

@@ -229,7 +232,7 @@ protected function executeOperation(PromiseAdapter $adapter, ServerConfig $confi
229232
*/
230233
protected function executeCacheableOperation(PromiseAdapter $adapter, ServerConfig $config, OperationParams $params, DocumentNode $document, $validate = TRUE) {
231234
$contextCacheId = 'ccid:' . $this->cacheIdentifier($params, $document);
232-
if (!$config->getDebug() && $contextCache = $this->cacheBackend->get($contextCacheId)) {
235+
if (!$config->getDebugFlag() && $contextCache = $this->cacheBackend->get($contextCacheId)) {
233236
$contexts = $contextCache->data ?: [];
234237
$cid = 'cid:' . $this->cacheIdentifier($params, $document, $contexts);
235238
if ($cache = $this->cacheBackend->get($cid)) {

0 commit comments

Comments
 (0)