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

  1. Use Drupal 9.5
  2. Have a view listing all redirects
  3. Make this view available in GraphQL
  4. Query this view:
    query {
      entityById(entityType:VIEW, id:"redirect") {
        label
        ... on View {
          e1: executable {
            ... on ViewRedirectDefault {
            	execute(page:0, limit: 5) {	
                total_rows
              }
            }
          }
        }
      }
    }
  5. 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

cweiske created an issue.

cweiske’s picture

Alternatively, a Drupal version check could be used - this would make it possible to have a stable Drupal 9 compatible version of graphql_core_schema:

if (version_compare(\Drupal::VERSION, '10.1', '>=')) {
  //new
} else {
  //old
}

But I'm not sure if that's wanted.