Contentful logo

Contentful Community

Resolving nested/circular entries

Hi,

I’m trying to query a contentmodel (“Collection”) that has a field “Productmodels” (References, many).
Those “Productmodels” themselves have a field “Othersizes” (References, many) that refer to other “Productmodels” underneath the “Collection” (added an json as example at the bottom).
When I get a “Collection” like this, I see the links to all the “Productmodels” attached to the received json, but when the GetEntries() call returns a “ContentfullCollection”, I only get 1 “Productmodel” underneat the “Collection” that are not referenced yet as “Othersizes”.
Some debugging led me to believe that all the links that are already processed (in this case as “Othersize”) are not included in any further processing.
Is there any way or flag that I can get these to proces correctly or is this just impossible to prevent endless loops of linkresolving? I already tested with different .Include() settings, but so far nothing seems to help.

Many thanks in advance,
aSt

{
  "sys": {
    "id": "1"
  },
  "title": "collection",
  "products": [
    {
      "sys": {
        "id": "product1"
      },
      "othersizes": [
        {
          "sys": {
            "id": "product2"
          },
          "othersizes": []
        },
        {
          "sys": {
            "id": "product3"
          },
          "othersizes": []
        }
      ]
    },
    {
      "sys": {
        "id": "product2"
      },
      "othersizes": [
        {
          "sys": {
            "id": "product1"
          },
          "othersizes": []
        },
        {
          "sys": {
            "id": "product3"
          },
          "othersizes": []
        }
      ]
    },
    {
      "sys": {
        "id": "product3"
      },
      "othersizes": [
        {
          "sys": {
            "id": "product1"
          },
          "othersizes": []
        },
        {
          "sys": {
            "id": "product2"
          },
          "othersizes": []
        }
      ]
    }
  ]
}

Hi!

You can try to set ResolveEntriesSelectively to true on your client. I wrote about it here: Robert Linde

Best
Robert

Hi Robert,
thanks a lot for the very fast reply! Interesting read and solved my problem perfectly!

Kind regards,
aSt.

1 Like