drupal-graphql / drupal-graphql/graphql

[4.x] property_path DataProducer resolver function fetchDataByPropertyPath() does not pass language parameter

Open
#1,380 0 comments 0 reactions 0 assignees View on GitHub
4.x
Dominant language
PHP
Stars
287
Forks
198
PR merge metrics
No merged PRs in 30d

Description

While querying paragraph content in translated languages, found that property_path DataProducer resolve calls the function fetchDataByPropertyPath() at line 69 of graphql/src/Plugin/GraphQL/DataProducer/TypedData/PropertyPath.php, but does not pass the language parameter.

I tried to pass the language as 4th parameter, but it fails in the module typed_data/src/DataFetcher.php at line 57 where it checks if the typed_data passed is instanceof TranslatableInterface, which results in false, hence it returns the output in default language.

I work around this by below code in public function resolve in PropertyPath.php

> $context_lang = $value->getValue()->language()->getId();
> if ($output instanceof TranslatableInterface && $output->hasTranslation($context_lang)) {
> $output = $output->getTranslation($context_lang);
> }

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.