From 222d9cbb7bd386e74021e28c0dd575ad09943188 Mon Sep 17 00:00:00 2001 From: Laureatus Date: Wed, 17 May 2023 15:01:59 +0200 Subject: [PATCH 01/15] Update module version to ^10 --- graphql.info.yml | 2 +- modules/graphql_core/graphql_core.info.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/graphql.info.yml b/graphql.info.yml index 75ee8d428..83db9d7da 100644 --- a/graphql.info.yml +++ b/graphql.info.yml @@ -3,4 +3,4 @@ type: module description: 'Base module for integrating GraphQL with Drupal.' package: GraphQL configure: graphql.config_page -core_version_requirement: ^8.8 || ^9 +core_version_requirement: ^10 diff --git a/modules/graphql_core/graphql_core.info.yml b/modules/graphql_core/graphql_core.info.yml index 162f971c8..04f32814b 100644 --- a/modules/graphql_core/graphql_core.info.yml +++ b/modules/graphql_core/graphql_core.info.yml @@ -2,6 +2,6 @@ name: GraphQL Core type: module description: 'Provides type system plugins and derivers on behalf of core modules.' package: GraphQL -core_version_requirement: ^8.8 || ^9 +core_version_requirement: ^10 dependencies: - graphql:graphql From 485bea92e7bd35b568f6e5855ad6a679721b9572 Mon Sep 17 00:00:00 2001 From: Laureatus Date: Wed, 17 May 2023 15:08:13 +0200 Subject: [PATCH 02/15] DRUPAL-495 Remove deprecated library and replace with supported library --- graphql.libraries.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphql.libraries.yml b/graphql.libraries.yml index 8e9dd9c69..0653ae802 100644 --- a/graphql.libraries.yml +++ b/graphql.libraries.yml @@ -9,7 +9,7 @@ explorer: dependencies: - core/drupal - core/jquery - - core/jquery.once + - core/once voyager: version: VERSION @@ -23,4 +23,4 @@ voyager: dependencies: - core/drupal - core/jquery - - core/jquery.once + - core/once From 88fb6d1712cc73f6d90ad6ba9db112aac0ea2392 Mon Sep 17 00:00:00 2001 From: Laureatus Date: Wed, 17 May 2023 15:46:57 +0200 Subject: [PATCH 03/15] DRUPAL-495 Update core version requirements --- graphql.info.yml | 2 +- modules/graphql_core/graphql_core.info.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/graphql.info.yml b/graphql.info.yml index 83db9d7da..e47e47bbf 100644 --- a/graphql.info.yml +++ b/graphql.info.yml @@ -3,4 +3,4 @@ type: module description: 'Base module for integrating GraphQL with Drupal.' package: GraphQL configure: graphql.config_page -core_version_requirement: ^10 +core_version_requirement: ^8 || ^9 || ^10 diff --git a/modules/graphql_core/graphql_core.info.yml b/modules/graphql_core/graphql_core.info.yml index 04f32814b..755b9e070 100644 --- a/modules/graphql_core/graphql_core.info.yml +++ b/modules/graphql_core/graphql_core.info.yml @@ -2,6 +2,6 @@ name: GraphQL Core type: module description: 'Provides type system plugins and derivers on behalf of core modules.' package: GraphQL -core_version_requirement: ^10 +core_version_requirement: ^8 || ^9 || ^10 dependencies: - graphql:graphql From 6848eef0c5963842eaa5ce42f08668b840d5d5fb Mon Sep 17 00:00:00 2001 From: "lorin.fankhauser" Date: Wed, 24 May 2023 10:53:58 +0200 Subject: [PATCH 04/15] Update webonyx/graphql-php from ^^0.12.5 to ^15.4.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 148e470f8..35200cdca 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "homepage": "http://drupal.org/project/graphql", "license": "GPL-2.0+", "require": { - "webonyx/graphql-php": "^0.12.5" + "webonyx/graphql-php": "^15.4.0" }, "minimum-stability": "dev" } From 740335b1f4c836887864bfc00dec726d192ae988 Mon Sep 17 00:00:00 2001 From: Laureatus Date: Tue, 30 May 2023 10:55:10 +0200 Subject: [PATCH 05/15] Rename methods to fit new webonyx version --- src/GraphQL/Execution/QueryProcessor.php | 4 ++-- src/Plugin/GraphQL/Schemas/SchemaPluginBase.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GraphQL/Execution/QueryProcessor.php b/src/GraphQL/Execution/QueryProcessor.php index fb2ad50fc..ff3563353 100644 --- a/src/GraphQL/Execution/QueryProcessor.php +++ b/src/GraphQL/Execution/QueryProcessor.php @@ -194,7 +194,7 @@ protected function executeOperation(PromiseAdapter $adapter, ServerConfig $confi // only work through POST requests. One cannot have mutations and queries // in the same document, hence this check is sufficient. $operation = $params->operation; - $type = AST::getOperation($document, $operation); + $type = AST::concatAST($document, $operation); if ($params->isReadOnly() && $type !== 'query') { throw new RequestError('GET requests are only supported for query operations.'); } @@ -432,7 +432,7 @@ protected function resolveValidationRules(ServerConfig $config, OperationParams * @throws \GraphQL\Server\RequestError */ protected function loadPersistedQuery(ServerConfig $config, OperationParams $params) { - if (!$loader = $config->getPersistentQueryLoader()) { + if (!$loader = $config->getPersistedQueryLoader()) { throw new RequestError('Persisted queries are not supported by this server.'); } diff --git a/src/Plugin/GraphQL/Schemas/SchemaPluginBase.php b/src/Plugin/GraphQL/Schemas/SchemaPluginBase.php index dc60dd9d9..d052ea0b0 100644 --- a/src/Plugin/GraphQL/Schemas/SchemaPluginBase.php +++ b/src/Plugin/GraphQL/Schemas/SchemaPluginBase.php @@ -288,7 +288,7 @@ public function getServer() { $config->setPersistentQueryLoader([$this->queryProvider, 'getQuery']); $config->setQueryBatching(TRUE); - $config->setDebug(!!$this->parameters['development']); + $config->setDebugFlag(!!$this->parameters['development']); $config->setSchema($this->getSchema()); // Always log the errors. From 2c266d601d922d0424153875c54a673eb6734bca Mon Sep 17 00:00:00 2001 From: Laureatus Date: Tue, 30 May 2023 11:12:18 +0200 Subject: [PATCH 06/15] Rename methods to fit new webonyx version --- src/Plugin/GraphQL/Schemas/SchemaPluginBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/GraphQL/Schemas/SchemaPluginBase.php b/src/Plugin/GraphQL/Schemas/SchemaPluginBase.php index d052ea0b0..87889351f 100644 --- a/src/Plugin/GraphQL/Schemas/SchemaPluginBase.php +++ b/src/Plugin/GraphQL/Schemas/SchemaPluginBase.php @@ -286,7 +286,7 @@ public function getServer() { return array_values(DocumentValidator::defaultRules()); }); - $config->setPersistentQueryLoader([$this->queryProvider, 'getQuery']); + $config->setPersistedQueryLoader([$this->queryProvider, 'getQuery']); $config->setQueryBatching(TRUE); $config->setDebugFlag(!!$this->parameters['development']); $config->setSchema($this->getSchema()); From dc0c1f7bb13968085cf8c0bf8b0c58bb665bc074 Mon Sep 17 00:00:00 2001 From: Laureatus Date: Tue, 30 May 2023 11:54:37 +0200 Subject: [PATCH 07/15] Change type of from DocumentNode to array --- src/GraphQL/Execution/QueryProcessor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/GraphQL/Execution/QueryProcessor.php b/src/GraphQL/Execution/QueryProcessor.php index ff3563353..f7e441d0d 100644 --- a/src/GraphQL/Execution/QueryProcessor.php +++ b/src/GraphQL/Execution/QueryProcessor.php @@ -194,7 +194,8 @@ protected function executeOperation(PromiseAdapter $adapter, ServerConfig $confi // only work through POST requests. One cannot have mutations and queries // in the same document, hence this check is sufficient. $operation = $params->operation; - $type = AST::concatAST($document, $operation); + $documentArray = AST::toArray($document); + $type = AST::concatAST($documentArray, $operation); if ($params->isReadOnly() && $type !== 'query') { throw new RequestError('GET requests are only supported for query operations.'); } From fdc68fe6885360faa8af7a2f0ad4fc4b5f908850 Mon Sep 17 00:00:00 2001 From: Laureatus Date: Wed, 31 May 2023 08:19:11 +0200 Subject: [PATCH 08/15] Change rename getDebug() to getDebugFlag() --- src/GraphQL/Execution/QueryProcessor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GraphQL/Execution/QueryProcessor.php b/src/GraphQL/Execution/QueryProcessor.php index f7e441d0d..b2df3844d 100644 --- a/src/GraphQL/Execution/QueryProcessor.php +++ b/src/GraphQL/Execution/QueryProcessor.php @@ -154,8 +154,8 @@ protected function executeOperationWithReporting(PromiseAdapter $adapter, Server $result->setErrorsHandler($config->getErrorsHandler()); } - if ($config->getErrorFormatter() || $config->getDebug()) { - $result->setErrorFormatter(FormattedError::prepareFormatter($config->getErrorFormatter(), $config->getDebug())); + if ($config->getErrorFormatter() || $config->getDebugFlag()) { + $result->setErrorFormatter(FormattedError::prepareFormatter($config->getErrorFormatter(), $config->getDebugFlag())); } return $result; @@ -231,7 +231,7 @@ protected function executeOperation(PromiseAdapter $adapter, ServerConfig $confi */ protected function executeCacheableOperation(PromiseAdapter $adapter, ServerConfig $config, OperationParams $params, DocumentNode $document, $validate = TRUE) { $contextCacheId = 'ccid:' . $this->cacheIdentifier($params, $document); - if (!$config->getDebug() && $contextCache = $this->cacheBackend->get($contextCacheId)) { + if (!$config->getDebugFlag() && $contextCache = $this->cacheBackend->get($contextCacheId)) { $contexts = $contextCache->data ?: []; $cid = 'cid:' . $this->cacheIdentifier($params, $document, $contexts); if ($cache = $this->cacheBackend->get($cid)) { From 58c9be685a7093465ee01ae0abd939609aba8573 Mon Sep 17 00:00:00 2001 From: Laureatus Date: Wed, 31 May 2023 11:42:09 +0200 Subject: [PATCH 09/15] Add #[\ReturnTypeWillChange] to TypePluginManagerAggregator.php --- src/Plugin/TypePluginManagerAggregator.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Plugin/TypePluginManagerAggregator.php b/src/Plugin/TypePluginManagerAggregator.php index fc8f3b9d1..7ac8d491b 100644 --- a/src/Plugin/TypePluginManagerAggregator.php +++ b/src/Plugin/TypePluginManagerAggregator.php @@ -46,7 +46,8 @@ public function getTypeManager($type) { /** * {@inheritdoc} */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->pluginManagers); } -} \ No newline at end of file +} From 00423a0b48baf7610c0cc1534ca49512411c4199 Mon Sep 17 00:00:00 2001 From: Laureatus Date: Mon, 5 Jun 2023 15:06:59 +0200 Subject: [PATCH 10/15] Change AST:concatAST() to AST::getOperationAST --- src/GraphQL/Execution/QueryProcessor.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/GraphQL/Execution/QueryProcessor.php b/src/GraphQL/Execution/QueryProcessor.php index b2df3844d..eada6d021 100644 --- a/src/GraphQL/Execution/QueryProcessor.php +++ b/src/GraphQL/Execution/QueryProcessor.php @@ -194,8 +194,7 @@ protected function executeOperation(PromiseAdapter $adapter, ServerConfig $confi // only work through POST requests. One cannot have mutations and queries // in the same document, hence this check is sufficient. $operation = $params->operation; - $documentArray = AST::toArray($document); - $type = AST::concatAST($documentArray, $operation); + $type = AST::getOperationAST($document, $operation); if ($params->isReadOnly() && $type !== 'query') { throw new RequestError('GET requests are only supported for query operations.'); } From 63790a37f011f5bbe697f9f428fee0e53789c3f4 Mon Sep 17 00:00:00 2001 From: Laureatus Date: Mon, 5 Jun 2023 15:09:11 +0200 Subject: [PATCH 11/15] Change to ->operation --- src/GraphQL/Execution/QueryProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GraphQL/Execution/QueryProcessor.php b/src/GraphQL/Execution/QueryProcessor.php index eada6d021..41a27248c 100644 --- a/src/GraphQL/Execution/QueryProcessor.php +++ b/src/GraphQL/Execution/QueryProcessor.php @@ -200,7 +200,7 @@ protected function executeOperation(PromiseAdapter $adapter, ServerConfig $confi } // Only queries can be cached (mutations and subscriptions can't). - if ($type === 'query') { + if ($type->operation === 'query') { return $this->executeCacheableOperation($adapter, $config, $params, $document, !$persisted); } From 9e47cf4a99d6876412523fabbd52005bb76cc093 Mon Sep 17 00:00:00 2001 From: Laureatus Date: Wed, 7 Jun 2023 08:44:10 +0200 Subject: [PATCH 12/15] remove isReadOnly() and replace it with public property --- src/GraphQL/Execution/QueryProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GraphQL/Execution/QueryProcessor.php b/src/GraphQL/Execution/QueryProcessor.php index 41a27248c..3c8b06245 100644 --- a/src/GraphQL/Execution/QueryProcessor.php +++ b/src/GraphQL/Execution/QueryProcessor.php @@ -195,7 +195,7 @@ protected function executeOperation(PromiseAdapter $adapter, ServerConfig $confi // in the same document, hence this check is sufficient. $operation = $params->operation; $type = AST::getOperationAST($document, $operation); - if ($params->isReadOnly() && $type !== 'query') { + if ($params->readOnly && $type !== 'query') { throw new RequestError('GET requests are only supported for query operations.'); } From 351d2898c7d761aa8bbd5e0fecbd7132f98d29bc Mon Sep 17 00:00:00 2001 From: Laureatus Date: Wed, 7 Jun 2023 09:33:49 +0200 Subject: [PATCH 13/15] Upgrade core version requirements from 8 to 8.8 --- graphql.info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphql.info.yml b/graphql.info.yml index e47e47bbf..ba8a6bc86 100644 --- a/graphql.info.yml +++ b/graphql.info.yml @@ -3,4 +3,4 @@ type: module description: 'Base module for integrating GraphQL with Drupal.' package: GraphQL configure: graphql.config_page -core_version_requirement: ^8 || ^9 || ^10 +core_version_requirement: ^8.8 || ^9 || ^10 From 8aae78485ea2385d7e0ac4b67dfff2a4d03b8921 Mon Sep 17 00:00:00 2001 From: Laureatus Date: Wed, 7 Jun 2023 11:06:29 +0200 Subject: [PATCH 14/15] Replace ValidationContext with QueryValidationContext --- src/GraphQL/Execution/QueryProcessor.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/GraphQL/Execution/QueryProcessor.php b/src/GraphQL/Execution/QueryProcessor.php index 3c8b06245..577de25f9 100644 --- a/src/GraphQL/Execution/QueryProcessor.php +++ b/src/GraphQL/Execution/QueryProcessor.php @@ -24,7 +24,9 @@ use GraphQL\Utils\AST; use GraphQL\Utils\TypeInfo; use GraphQL\Utils\Utils; +use GraphQL\Validator\QueryValidationContext; use GraphQL\Validator\Rules\AbstractValidationRule; +use GraphQL\Validator\Rules\ValidationRule; use GraphQL\Validator\ValidationContext; use GraphQL\Validator\Rules\QueryComplexity; use Symfony\Component\HttpFoundation\RequestStack; @@ -350,8 +352,8 @@ protected function validateOperation(ServerConfig $config, OperationParams $para $schema = $config->getSchema(); $info = new TypeInfo($schema); - $validation = new ValidationContext($schema, $document, $info); - $visitors = array_values(array_map(function (AbstractValidationRule $rule) use ($validation, $params) { + $validation = new QueryValidationContext($schema, $document, $info); + $visitors = array_values(array_map(function (ValidationRule $rule) use ($validation, $params) { // Set current variable values for QueryComplexity validation rule case // @see \GraphQL\GraphQL::promiseToExecute for equivalent if ($rule instanceof QueryComplexity && !empty($params->variables)) { From c11afba6029b4ae8fce388b16d361fa029696dad Mon Sep 17 00:00:00 2001 From: Laureatus Date: Tue, 13 Jun 2023 09:25:32 +0200 Subject: [PATCH 15/15] Add getVisitor() method --- src/GraphQL/Execution/QueryProcessor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GraphQL/Execution/QueryProcessor.php b/src/GraphQL/Execution/QueryProcessor.php index 577de25f9..7d15d0ea6 100644 --- a/src/GraphQL/Execution/QueryProcessor.php +++ b/src/GraphQL/Execution/QueryProcessor.php @@ -24,12 +24,12 @@ use GraphQL\Utils\AST; use GraphQL\Utils\TypeInfo; use GraphQL\Utils\Utils; -use GraphQL\Validator\QueryValidationContext; use GraphQL\Validator\Rules\AbstractValidationRule; -use GraphQL\Validator\Rules\ValidationRule; use GraphQL\Validator\ValidationContext; use GraphQL\Validator\Rules\QueryComplexity; use Symfony\Component\HttpFoundation\RequestStack; +use GraphQL\Validator\Rules\ValidationRule; +use GraphQL\Validator\QueryValidationContext; // TODO: Refactor this and clean it up. class QueryProcessor { @@ -359,7 +359,7 @@ protected function validateOperation(ServerConfig $config, OperationParams $para if ($rule instanceof QueryComplexity && !empty($params->variables)) { $rule->setRawVariableValues($params->variables); } - return $rule($validation); + return $rule->getVisitor($validation); }, $rules)); // Run the query visitor with the prepared validation rules and the cache