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

The include query option doesn't work #1808

Open
AliRezaBeitari opened this issue May 4, 2023 · 5 comments
Open

The include query option doesn't work #1808

AliRezaBeitari opened this issue May 4, 2023 · 5 comments

Comments

@AliRezaBeitari
Copy link

Here is my code:

const s = await client.getSpace('**********')
const e = await s.getEnvironment('master')
const i = await e.getEntry('**********', { include: 10 })

console.log(i)

Here is the schema:

{
  ...

  "fields": [
    {
      "id": "children",
      "name": "Children",
      "type": "Array",
      "localized": false,
      "required": false,
      "validations": [],
      "disabled": false,
      "omitted": false,
      "items": {
        "type": "Link",
        "validations": [
          {
            "linkContentType": [
              "copyCopyRow",
              "articleImageRow",
              "articlePullQuote"
            ]
          }
        ],
        "linkType": "Entry"
      }
    }
  ]

  ...
}

When I query an entry, I expect to have the information for all of the entries inside the children field, but here is what is actually returned:

{
  ...

  "fields": {
    "children": {
      "en-US": [
        {
          "sys": {
            "type": "Link",
            "linkType": "Entry",
            "id": "************************"
          }
        },
        {
          "sys": {
            "type": "Link",
            "linkType": "Entry",
            "id": "************************"
          }
        },
        {
          "sys": {
            "type": "Link",
            "linkType": "Entry",
            "id": "************************"
          }
        },
        {
          "sys": {
            "type": "Link",
            "linkType": "Entry",
            "id": "************************"
          }
        }
      ]
    }
  }

  ...
}

Version: ^10.34.1

@mrkimbo
Copy link

mrkimbo commented May 15, 2023

Also seeing this issue. The response should either contain resolved entries or an Includes section where linked entries can be resolved.

@mrkimbo
Copy link

mrkimbo commented May 15, 2023

I think the wrapCollection utility just pulls out the items collection from the response.
Is this related to being able to subsequently update entries with linked items?

@mrkimbo
Copy link

mrkimbo commented May 22, 2023

@AliRezaBeitari FYI, I found the [Entry].references method and this fetches all of an entry's linked references.
I'm not certain, but I assume that as the entry may need to be updated at a later time, its linked entries are not included.

The includes data is returned in the original request, so it could be included in the original entry (somehow) to avoid having to re-request it. Might be opening a can of worms by doing that, though...

@pedroGenio
Copy link

I'm having a similar issue...
await environment.getEntries({ 'content_type': 'siteMenu', "fields.name": "Primary Menu", include: 10, })
"include" on contentful-management doesnt work
however, in contentful lib it works as intended

@zacharypodbela
Copy link

I am still facing this issue 6 months later 😢

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

4 participants