Versions
Drupal: 9.3.x, 9.4.x, 10
Gatsby: 2.0.0-beta2, 2.0.x
Problem/Motivation
When enabling the "Gatsby iframe preview" field (Manage Display) on a content type Drupal\Core\Entity\Controller\EntityViewController->buildTitle() produces a Notice
Steps to reproduce
1. Drag the "Gatsby iframe preview" field from Disabled on a content type
2. Create content using that content type
3. Error will be displayed on the node view

Proposed resolution
When gatsby_entity_view() replaces the $build array add the missing #node key:
$build['#node'] = $entity;
Remaining tasks
Create a patch.
User interface changes
API changes
Data model changes
Comments
Comment #2
scottalan commentedComment #3
scottalan commentedComment #4
damienmckennaWhat happens if you just remove the $build=[] line?
Comment #5
scottalan commentedIt renders any other fields that aren't disabled on the content type. In that case I guess one can just disable fields they don't want to see. I'm not sure there's any other reason $build is reinitialized as an empty array.
Comment #6
damienmckennaThanks for confirming it. This is the fix we need so that the entity display works as expected.
Comment #7
scottalan commentedSounds good
Comment #8
damienmckennaComment #9
damienmckennaComment #11
damienmckennaCommitted. Thank you!