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

Updates 3.x branch's webonyx/graphql-php to a version compatible with php 8.1 #1298

Conversation

loopy3025
Copy link

Hopefully resolves #1297

@loopy3025 loopy3025 changed the title Updates webonyx/graphql-php to a version compatible with php 8.1 Updates 3.x branch's webonyx/graphql-php to a version compatible with php 8.1 Aug 10, 2022
@loopy3025
Copy link
Author

Beuller?

@lahoosascoots
Copy link

lahoosascoots commented Sep 9, 2022

@loopy3025 If you don't hear back in time for EOL you can override the library in your root composer.json:

"webonyx/graphql-php": "14.11.6 as 0.12.6"

This may not actually work though I my graphql endpoints are now throwing:

Error: Call to undefined method GraphQL\Server\ServerConfig::setDebug() in Drupal\graphql\Plugin\GraphQL\Schemas\SchemaPluginBase->getServer() (line 291 of modules/contrib/graphql/src/Plugin/GraphQL/Schemas/SchemaPluginBase.php).

@Oleksii909
Copy link

Oleksii909 commented Dec 29, 2022

@lahoosascoots Thank you for suggestion: "webonyx/graphql-php": "14.11.6 as 0.12.6" in root composer.
I got successfully run our site with graphql v3 with additional patches for graphql module using php v8.1:

+++ web/patches/graphql/ImageDerivative.php	2021-11-13 13:32:18.780641002 +0200
@@ -85,7 +85,7 @@
         $url = $style->buildUrl($file->getFileUri());
       }
       else {
-        $url = $file->url();
+        $url = $file->createFileUrl(FALSE);
       }
 
       yield new CacheableValue([
--- web/modules/contrib/graphql/src/GraphQL/Execution/QueryProcessor.php	2020-10-29 10:53:13
+++ web/patches/QueryProcessor.php.patched	2022-12-29 15:16:45
@@ -154,7 +154,8 @@
         $result->setErrorsHandler($config->getErrorsHandler());
       }
 
-      if ($config->getErrorFormatter() || $config->getDebug()) {
+//      if ($config->getErrorFormatter() || $config->getDebug()) {
+      if ($config->getErrorFormatter()) {
         $result->setErrorFormatter(FormattedError::prepareFormatter($config->getErrorFormatter(), $config->getDebug()));
       }
 
@@ -230,7 +231,8 @@
    */
   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->getDebug() && $contextCache = $this->cacheBackend->get($contextCacheId)) {
+    if ($contextCache = $this->cacheBackend->get($contextCacheId)) {
       $contexts = $contextCache->data ?: [];
       $cid = 'cid:' . $this->cacheIdentifier($params, $document, $contexts);
       if ($cache = $this->cacheBackend->get($cid)) {
--- web/modules/contrib/graphql/src/Routing/QueryRouteEnhancer.php	2020-10-29 10:53:13.000000000 +0200
+++ web/patches/graphql/QueryRouteEnhancer.php	2021-11-13 13:26:33.795717042 +0200
@@ -31,9 +31,9 @@
     // graphql processor due to a missing query string but at least provides
     // the right format for the client to act upon.
     return $defaults + [
-      '_controller' => $defaults['_graphql']['single'],
-      'operations' => $operations,
-    ];
+//        '_controller' => $defaults['_graphql']['single'],
+        'operations' => $operations,
+      ];
   }
 
   /**
--- web/modules/contrib/graphql/src/Plugin/GraphQL/Schemas/SchemaPluginBase.php	2020-10-29 10:53:13
+++ web/patches/SchemaPluginBase.php.patched	2022-12-29 14:47:07
@@ -288,7 +288,7 @@
 
     $config->setPersistentQueryLoader([$this->queryProvider, 'getQuery']);
     $config->setQueryBatching(TRUE);
-    $config->setDebug(!!$this->parameters['development']);
+//    $config->setDebug(!!$this->parameters['development']);
     $config->setSchema($this->getSchema());
 
     // Always log the errors.
--- web/modules/contrib/graphql/src/Plugin/TypePluginManagerAggregator.php	2022-12-29 15:03:33
+++ web/patches/TypePluginManagerAggregator.php.patched	2022-12-29 14:54:52
@@ -46,7 +46,8 @@
   /**
    * {@inheritdoc}
    */
-  public function getIterator() {
+//  public function getIterator() {
+  public function getIterator(): \IteratorAggregate {
     return new \ArrayIterator($this->pluginManagers);
   }
 }

@zuernBernhard
Copy link

Yes can confirm it works. This is my patch file:

1298.txt

@Oleksii909
Copy link

Thank you, I will test it. soon

@dilshan-g
Copy link

Hi @Oleksii909 and @zuernBernhard with the composer override and the patch file change. I managed to get the below error fixed.
Deprecated function: Return type of Drupal\graphql\Plugin\TypePluginManagerAggregator::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 5 of /var/www/docroot/modules/contrib/graphql/src/Plugin/TypePluginManagerAggregator.php).

My GQL feed is also working now, but I'm seeing this below error on top of the feed on Drupal GQL explorer
"errors": [ { "message": "Internal server error", "extensions": { "category": "internal" }, "locations": [ { "line": 18, "column": 9 } ], "path": [ "route", "nodeContext", "entityMetatags" ] } ],

And on Drupal logs I can see this Error:
Call to undefined method Drupal\node\Entity\Node::url()

Do you guys have any idea if this is related ?

@zuernBernhard
Copy link

zuernBernhard commented Mar 24, 2023 via email

@Luigisa
Copy link

Luigisa commented Sep 7, 2023

This request has already been implemented in the latest version of the module.

https://github.com/drupal-graphql/graphql/blob/8.x-3.x/composer.json#L8

Thank you.

@Luigisa Luigisa closed this Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants