Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.x 3.x alpha1 #1

Open
wants to merge 15 commits into
base: 8.x-3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion graphql.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions graphql.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ explorer:
dependencies:
- core/drupal
- core/jquery
- core/jquery.once
- core/once

voyager:
version: VERSION
Expand All @@ -23,4 +23,4 @@ voyager:
dependencies:
- core/drupal
- core/jquery
- core/jquery.once
- core/once
2 changes: 1 addition & 1 deletion modules/graphql_core/graphql_core.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 12 additions & 10 deletions src/GraphQL/Execution/QueryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.');
}

Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/GraphQL/Schemas/SchemaPluginBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/Plugin/TypePluginManagerAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function getTypeManager($type) {
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function getIterator() {
return new \ArrayIterator($this->pluginManagers);
}
}
}