Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get data from linked INLINES.ENTRY_HYPERLINK #346

Open
rutgerbakker95 opened this issue Jun 29, 2022 · 2 comments
Open

How to get data from linked INLINES.ENTRY_HYPERLINK #346

rutgerbakker95 opened this issue Jun 29, 2022 · 2 comments

Comments

@rutgerbakker95
Copy link

Hi,

I'd link to add hyperlinks and links to entries in my rich-text field. Is there a way to receive data from the linked entry? Currently I'm only getting the sys.id of the linked entry...

Query:

query {
  pageHomepage(id: "7gBE67AMfi2O7fRM2D7xGL") {
    content {
      json
      links {
        entries {
          hyperlink {
            sys {
              id
            }
            contentfulMetadata {
              tags {
                id
                name
              }
            }
            __typename
          }
        }
      }
    }
  }
}

Output:

{
  "data": {
    "pageHomepage": {
      "content": {
        "json": {
          "nodeType": "document",
          "data": {},
          "content": [
            {
              "nodeType": "paragraph",
              "data": {},
              "content": [
                {
                  "nodeType": "text",
                  "value": "",
                  "marks": [],
                  "data": {}
                },
                {
                  "nodeType": "entry-hyperlink",
                  "data": {
                    "target": {
                      "sys": {
                        "id": "2K5KHMn7Gn0Vt13x11Es6n",
                        "type": "Link",
                        "linkType": "Entry"
                      }
                    }
                  },
                  "content": [
                    {
                      "nodeType": "text",
                      "value": "I'd like to get the slug of the linked entry",
                      "marks": [],
                      "data": {}  # need some data from linked entry
                    }
                  ]
                },
                {
                  "nodeType": "text",
                  "value": "",
                  "marks": [],
                  "data": {}
                }
              ]
            }
          ]
        },
        "links": {
          "entries": {
            "hyperlink": [
              {
                "sys": {
                  "id": "2K5KHMn7Gn0Vt13x11Es6n"
                },
                "contentfulMetadata": {
                  "tags": []
                },
                "__typename": "PageMethod"
              }
            ]
          }
        }
      }
    }
  }
}
@rutgerbakker95 rutgerbakker95 changed the title How to get field from linked INLINES.ENTRY_HYPERLINK How to get data from linked INLINES.ENTRY_HYPERLINK Jun 29, 2022
@mdugue
Copy link

mdugue commented Aug 2, 2022

@rutgerbakker95 I just stumbled upon the same problem. Did you find any solution by now?

@Thomas-Machielsen
Copy link

You probably need to pass the include parameter to your getEntries call.

https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/links/retrieval-of-linked-items

This is how we use it:

const index = await getEntries({ content_type: 'index', include: 10 });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants