Problem/Motivation
When fetching view data via GraphQL in Drupal 9.5, I get an exception:
Error: Call to undefined method Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\ViewExecutor::getEntityTranslationByRelationship()
in Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\ViewExecutor->Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\{closure}()
(line 237 of modules/contrib/graphql_core_schema/src/Plugin/GraphQL/DataProducer/ViewExecutor.php).
EntityTranslationRenderTrait::getEntityTranslationByRelationship() was introduced in Drupal 10.1 and the previous EntityTranslationRenderTrait::getEntityTranslation() method was deprecated and removed with Drupal 11.
graphql_core_schema switched from getEntityTranslation() to getEntityTranslationByRelationship() with commit 140dd4ff which was released with 1.0.0.
Version 1.0.0-beta7 was the last one that was compatible with Drupal 9 - but composer.json as of 1.0.24 does not say anything about Drupal core compatibility.
Steps to reproduce
- Use Drupal 9.5
- Have a view listing all redirects
- Make this view available in GraphQL
- Query this view:
query { entityById(entityType:VIEW, id:"redirect") { label ... on View { e1: executable { ... on ViewRedirectDefault { execute(page:0, limit: 5) { total_rows } } } } } } - Get exception
Proposed resolution
Either mark graphql_core_schema as incompatible with Drupal 9 (all versions since 1.0.0), or fall back to the old getEntityTranslation() method with Drupal 9.
Stack trace
Error: Call to undefined method Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\ViewExecutor::getEntityTranslationByRelationship() in Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\ViewExecutor->Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\{closure}() (line 237 of modules/contrib/graphql_core_schema/src/Plugin/GraphQL/DataProducer/ViewExecutor.php).
Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\ViewExecutor->Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\{closure}() (Line: 107)
Drupal\graphql_core_schema\GraphQL\Buffers\SubRequestBuffer->Drupal\graphql_core_schema\GraphQL\Buffers\{closure}()
array_map() (Line: 106)
Drupal\graphql_core_schema\GraphQL\Buffers\SubRequestBuffer->Drupal\graphql_core_schema\GraphQL\Buffers\{closure}() (Line: 63)
Drupal\graphql_core_schema\EventSubscriber\CoreSchemaSubrequestSubscriber->Drupal\graphql_core_schema\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 64)
Drupal\graphql_core_schema\EventSubscriber\CoreSchemaSubrequestSubscriber->onKernelResponse()
call_user_func() (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 202)
Symfony\Component\HttpKernel\HttpKernel->filterResponse() (Line: 148)
Comments
Comment #2
cweiske commentedAlternatively, a Drupal version check could be used - this would make it possible to have a stable Drupal 9 compatible version of graphql_core_schema:
But I'm not sure if that's wanted.