Problem/Motivation
A content type has an entity reference field.
A node "foo" of that content type references an unpublished node "bar".
Viewing the node "foo" as an anonymous user will create caches.
When publishing the node "bar" it is expected to become visible on the page "foo" but that page won't show the referenced node "bar" that is now published.
EntityReferenceEntityFormatter::viewElements only adds accessible nodes to the render array (not the unpublished or inaccessible ones) but a node that is referenced might be inaccessible at first and become accessible later.
Proposed resolution
We need to add cache tags for referenced entities that are not accessible. => This is what the patch in #8 does but the problem is with 'hook_node_grants'; The access function doesn't add the node as cacheable dependency.
This should be fixed in the node module by merging multiple access results together (possibly in NodeAccessControlHandler).