Как в Sanity groq получить ссылку из определенного _type в массиве объектов?

В Sanity groq я могу указать страницу с массивами, используя:

что дает мне дамп JSON:

и я пытаюсь получить ссылку internalLink

пытался:

но мой ответ:

пытался:

но я получаю:

В groq из массива объектов для определенного типа, в этом случае barsTues как я могу получить справочную информацию, не получая повторение объектов, которые приводят к нулю? Мне по-прежнему нужно все из ....

*[_type == "page" && slug.current == $slug][0]  {
   ...fooBar {
      bars [] {
        ..., 
      }
   }
}
{
  "bars": [
    {
      "_type": "barsMon",
      "_key": "efa4087f356a",
      "body": "Bacon ipsum dolor amet andouille venison doner kevin. Cow salami sausage t-bone. "
    },
    {
      "_type": "barsTues",
      "_key": "791437e4eedf",
      "cta": {
        "_type": "cta",
        "link": {
          "_type": "link",
          "linkType": "internal",
          "internalLink": {
            "_type": "reference",
            "_ref": "70cde2de-3cb0-4591-abb2-a677614089ba"
          }
        }
      }
    }
  ]
}
*[_type == "page" && slug.current == $slug][0]  {
   ...fooBar {
      bars [] {
        ...,
       "barsTues": *[_type == "barsTues"] {
         ...
        }
      }
   }
}
{
  "bars": [
    {
      "_type": "barsMon",
      "_key": "efa4087f356a",
      "body": "Bacon ipsum dolor amet andouille venison doner kevin. Cow salami sausage t-bone. ",
      "barsTues": []
    },
    {
      "_key": "791437e4eedf",
      "cta": {
        "_type": "cta",
        "link": {
          "internalLink": {
            "_type": "reference",
            "_ref": "70cde2de-3cb0-4591-abb2-a677614089ba"
          },
          "_type": "link",
          "linkType": "internal"
        }
      },
      "_type": "barsTues",
      "barsTues": []
    }
  ]
}
*[_type == "page" && slug.current == $slug][0]  {
   ...fooBar {
      bars [] {
        ...,
       barsTues {
         ...
       }
      }
   }
}
{
  "bars": [
    {
      "body": "Bacon ipsum dolor amet andouille venison doner kevin. Cow salami sausage t-bone. ",
      "barsTues": null,
      "_type": "barsMon",
      "_key": "efa4087f356a"
    },
    {
      "barsTues": null,
      "cta": {
        "_type": "cta",
        "link": {
          "_type": "link",
          "linkType": "internal",
          "internalLink": {
            "_ref": "70cde2de-3cb0-4591-abb2-a677614089ba",
            "_type": "reference"
          }
        }
      },
      "_type": "barsTues",
      "_key": "791437e4eedf"
    }
  ]
}
Панкратий
Вопрос задан8 августа 2024 г.

1 Ответ

2
Фаина
Ответ получен2 сентября 2024 г.

Ваш ответ

Загрузить файл.