drupal-graphql / graphql

GraphQL integration for Drupal 9/10
288 stars 201 forks source link

drupal-graphql#1322: Fix fatal error when attempting to load an entity for a language the entity is not translated into. #1388

Open vermario opened 10 months ago

vermario commented 10 months ago

If an entity is requested directly with a translation that it does not yet have, currently we see a fatal error, because the code tries to load the entity translation before checking for its existence.

This was noted by @artemvd in https://github.com/drupal-graphql/graphql/issues/1322.

The PR that was created #1323 didn't fix the issue in two additional plugins, this PR does, by adding the same code.

almunnings commented 10 months ago

Does it need to return NULL?

Just wrapping the getTranslation with hasTranslation might be the desired outcome, with a fallback to default content.

Edit: Nevermind, I just read the linked PR from previous conversation. Allll good.

klausi commented 8 months ago

I think this makes sense. I was thinking if we need to add cache information before returning NULL, but since it should vary per language parameter anyway I think this is fine.

Can you add a test case to cover this?

smavri-axess commented 6 months ago

It's missing also the fix in the DataProducer TaxonomyLoadTree.