question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to access paragraphs data

See original GitHub issue

Hi, first and foremost, thanks for a great integration with Drupal!

We’re trying this out and we’re running into issues when trying to populate paragraphs data to our basic pages.

In [...slug].tsx we’re including field_content which holds all our paragraphs:

if (type === "node--page") {
  params = {
    include: "field_content",
  }
}

When we console.log our response (the entire node data) we can see that there is a paragraph called paragraph--hero which is good. But we can’t access the data nested inside the paragraph:

CleanShot 2022-06-20 at 08 16 19@2x

When we check our api-response locally (http://localhost/jsonapi/node/page?include=field_content), we can see that our nested paragraph data lives inside the included part of the response:

CleanShot 2022-06-20 at 08 13 36@2x

Sadly the included part is not available to us when we console log the entire node data:

CleanShot 2022-06-20 at 08 23 55@2x

Does anyone have a solution or know how to access the nested data? We need this to be able to build dynamic pages.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
LarssonHenrikcommented, Jun 21, 2022

Hi again @shadcn!

I continued to investigate this yesterday and it seems like I hadn’t configured the module Paragraphs Type Permissions properly.

After I configured that anonymous users would be able to view my Hero paragraph, the data is now showing up in my response.

CleanShot 2022-06-21 at 07 57 42@2x

Thanks for all your help and feedback!

0reactions
simon-olsencommented, Aug 3, 2022

Just dropping this here in case anyone else needs help with this. I don’t have any Paragraph Type permissions added to my Drupal site. I was able to access my Paragraph and the Media asset within it with the following:

My paragraphs field is Body variation with a Paragraph Type of Image and body text which has an image, a select field for image position (above, left or right) and the Body continued field.

For the include on my node--article type in getStaticProps

if (type === "node--article") {
    params = {
      include:
        "field_body_variation.field_image_asset.field_media_image,uid",
    };
  }

This gives me all three fields in my response. If I just add field_body_variation without the .field_image_asset.field_media_image I’m not able to see the path to the asset in the Media Library in my response.

field_body_continued:
    format: "basic_html"
    processed: "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam et fermentum dui. Ut orci quam, ornare sed lorem sed, hendrerit auctor dolor. Nulla viverra, nibh quis ultrices malesuada, ligula ipsum vulputate diam, aliquam egestas nibh ante vel dui. Sed in tellus interdum eros vulputate placerat sed non enim. Pellentesque eget.</p>\n"
    value: "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam et fermentum dui. Ut orci quam, ornare sed lorem sed, hendrerit auctor dolor. Nulla viverra, nibh quis ultrices malesuada, ligula ipsum vulputate diam, aliquam egestas nibh ante vel dui. Sed in tellus interdum eros vulputate placerat sed non enim. Pellentesque eget.</p>\r\n"
field_image_asset:
    field_media_image:
        changed: "2022-08-03T10:45:37+00:00"
        created: "2022-08-03T10:45:23+00:00"
        resourceIdObjMeta: {alt: 'Photograph of Australian outback', title: null, width: 4608, height: 3072, drupal_internal__target_id: 5}
        uri: {value: 'public://2022-08/pexels-pixabay-162379-small.jpg', url: '/sites/bradhazzard/files/2022-08/pexels-pixabay-162379-small.jpg'}
field_image_position: "above"

I got stuck on this while trying to use Paragraphs that use Media assets (as opposed to a simple Image field). Hope this helps someone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Paragraphs do not render: access check for "view" fail ... - Drupal
I was using the patch from #11, but encountered an issue where many paragraphs stopped displaying because of being access denied. The cause...
Read more >
Paragraph "view" access error - Drupal Answers
I have a weird issue. I created a custom profile using the Profile module. This profile has some classic fields and some paragraph...
Read more >
Data types for Access desktop databases - Microsoft Support
Data Type Usage Size Short Text (formerly known as “Text”) Alphanumeric data (names, titles, etc.) Up to 255 char... Number Numeric data. 1, 2, 4,...
Read more >
getByRole query for paragraph not working during React testing
getByRole uses the HTML role of different elements. Paragraph is not a valid role, that's why your query doesn't work.
Read more >
OECD Guidelines on the Protection of Privacy and ...
Click here to access the revised Guidelines ... Indeed, it is probably not possible to identify a set of data which are universally...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found