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" } diff --git a/graphql.info.yml b/graphql.info.yml index 75ee8d428..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.8 || ^9 +core_version_requirement: ^8.8 || ^9 || ^10 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 diff --git a/modules/graphql_core/graphql_core.info.yml b/modules/graphql_core/graphql_core.info.yml index 162f971c8..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: ^8.8 || ^9 +core_version_requirement: ^8 || ^9 || ^10 dependencies: - graphql:graphql diff --git a/src/GraphQL/Execution/QueryProcessor.php b/src/GraphQL/Execution/QueryProcessor.php index fb2ad50fc..7d15d0ea6 100644 --- a/src/GraphQL/Execution/QueryProcessor.php +++ b/src/GraphQL/Execution/QueryProcessor.php @@ -28,6 +28,8 @@ 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 { @@ -154,8 +156,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; @@ -194,13 +196,13 @@ 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); - if ($params->isReadOnly() && $type !== 'query') { + $type = AST::getOperationAST($document, $operation); + if ($params->readOnly && $type !== 'query') { throw new RequestError('GET requests are only supported for query operations.'); } // 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); } @@ -230,7 +232,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)) { @@ -350,14 +352,14 @@ 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)) { $rule->setRawVariableValues($params->variables); } - return $rule($validation); + return $rule->getVisitor($validation); }, $rules)); // Run the query visitor with the prepared validation rules and the cache @@ -432,7 +434,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..87889351f 100644 --- a/src/Plugin/GraphQL/Schemas/SchemaPluginBase.php +++ b/src/Plugin/GraphQL/Schemas/SchemaPluginBase.php @@ -286,9 +286,9 @@ public function getServer() { return array_values(DocumentValidator::defaultRules()); }); - $config->setPersistentQueryLoader([$this->queryProvider, 'getQuery']); + $config->setPersistedQueryLoader([$this->queryProvider, 'getQuery']); $config->setQueryBatching(TRUE); - $config->setDebug(!!$this->parameters['development']); + $config->setDebugFlag(!!$this->parameters['development']); $config->setSchema($this->getSchema()); // Always log the errors. 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 +}