Contentful Embedded Content in Gatsby
This is specifically for Gatsby as that's what I was using, but I suppose the implementation will be similar in other React/GraphQL environments.
When using @contentful/rich-text-react-renderer to render a Contentful entry, they suggest passing a custom rendering component for embedded entries.
However, I was unable to get a fully populated node
in the render handlers that would contain all the fields I require, with only access to the contentful_id
and the entry type. Whatever I fetched in graphql was available in the references
key of the content body
, but it wasn't being sent on. Didn't bother to check how this works under the hood, but managed to achieve what I wanted by passing the references
object to the custom renderer and searching for the relevant entry by contentful_id
.