Paragraph contextual filter I would like to create "related item" with paragraphs.

I have 2 content type using paragraph field. This paragraph field has different options, like "quotes, related items, slider" etc.

I want to get some fields from "related item". "Related item" field is a "Entity reference".

Inside paragraphs type I have one called "related item"


Inside this I have a field type "entity reference"

I have different pages where I can add this paragraph and choose the entity.

I want to get specific fields from this entity type.

I know I can acomplish this with a view, relationship and contextual filters, but I don't how to do this with a paragraph or if it is possible.
You may have to jump through several hoops to get the data from the entity reference field.

  // Query entity types  
  $query = \Drupal::entityQuery('node');
  $query-&gt;condition('status', 1);
  $query-&gt;condition('type', 'your_content_type');
  $entity_ids = $query-&gt;execute();

  // Query paragraph types
  $paragraph = \Drupal::entityQuery('paragraph');
  $paragraph-&gt;condition('status', 1);
  $paragraph-&gt;condition('type', 'paragraph_type');
  $paragraph_ids = $paragraph-&gt;execute();

  // Loop through entity IDs
  $paragraph_output = array();
  foreach($paragraph_ids as $pid){

    // Load each paragraph
    $paragraph = Paragraph::load($pid);

    // Load each entity reference field
    $entity_id = $paragraph-&gt;get('field_entity_identifier')-&gt;getValue();

    // Get entity parent Node ID
    $parent_node = \Drupal::entityManager()-&gt;getStorage('node')-&gt;load($parent_id[0]['value']);

    // You'll need to insert another foreach loop here drilling down further into the node that is being referenced.

  }


First you have to loop through the content types. Then you have to look to see if those paragraphs are set and have data. Then you loop through the paragraph types data and get the nodes they reference. Then you have to loop referenced nodes. 

It's not an exact solution, but it's how I load data in modules and create my own API endpoints for some fairly heavy frontend javascript applications.