contentful-management.js icon indicating copy to clipboard operation
contentful-management.js copied to clipboard

The `include` query option doesn't work

Open AliRezaBeitari opened this issue 1 year ago • 5 comments

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

AliRezaBeitari avatar May 04 '23 20:05 AliRezaBeitari

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

mrkimbo avatar May 15 '23 03:05 mrkimbo

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 avatar May 15 '23 06:05 mrkimbo

@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...

mrkimbo avatar May 22 '23 02:05 mrkimbo

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

pedroGenio avatar Oct 25 '23 23:10 pedroGenio

I am still facing this issue 6 months later 😢

zacharypodbela avatar May 20 '24 18:05 zacharypodbela