drupal-graphql / graphql

GraphQL integration for Drupal 9/10
287 stars 202 forks source link

Route Entity data producer with non-existing translation #1322

Open artemvd opened 1 year ago

artemvd commented 1 year ago

This plugin tries to load entity translation based on the language argument. But in case that translation doesn't exist Drupal's ContentEntityBase class throws exception Invalid translation language ($langcode) specified. .

I suggest to add check if translation exists before trying to get it.

artemvd commented 1 year ago

PR: https://github.com/drupal-graphql/graphql/pull/1323

hchonov commented 1 year ago

If the entity has been requested in a specific translation, that the entity does not have then I agree that the return value should be NULL since we cannot actually resolve the requested set of parameters.

jacintocapote commented 1 year ago

This looks like a perfect approach and is working perfect.

vermario commented 9 months ago

hi! I think this is a great fix, the same code exists though also in the EntityLoad and EntityLoadByUuid plugins, so I made a new PR: #1388 .