0

I would like to add the data (image, slug, title) for the type "galleryHp" from this query:

*[_type == "homePage"][0] {
      "modules": modulesFr,
}

this query returns a array with several modules, including the galleryHp module but with only the references and not the data (title, slug, image) for each join:

{
  "modules": [
    {
      "_key": "....",
      "subheading": ".....",
      "heading": ".....",
      "background": ".....",
      "_type": "heroHp"
    },
    {
      "subheading": ".....",
      "image": ".....",
      "heading": ".....",
      "_type": "profileHp",
      "_key": "...."
    },
    {
      "_key": "....",
      "modules": [
        {
          "_type": "reference",
          "_key": "....",
          "_ref": "...."
        },
        {
          "_key": "....",
          "_ref": "....",
          "_type": "reference"
        }
      ],
      "heading": "Galerie",
      "_type": "galleryHp"
    }
  ]
}

I would like to add the title, slug and image data for each item of galleryHp, to obtain a result like this:

{
  "modules": [
    {
      "_key": "....",
      "subheading": ".....",
      "heading": ".....",
      "background": ".....",
      "_type": "heroHp"
    },
    {
      "subheading": ".....",
      "image": ".....",
      "heading": ".....",
      "_type": "profileHp",
      "_key": "...."
    },
    {
      "_key": "....",
      "modules": [
        {
          "image": "....",
          "slug": "....",
          "title": "...."
        },
        {
         "image": "....",
          "slug": "....",
          "title": "...."
        }
      ],
      "heading": "...",
      "_type": "galleryHp"
    }
  ]
}
thetiti
  • 95
  • 2
  • 7

0 Answers0