Skip to content

Webhooks do not populate nested components like Media Component. #17003

@Emadeddin-eibo

Description

@Emadeddin-eibo

Bug report

Required System information

  • Node.js version: 14.21.3
  • NPM version: 6.14.18
  • Strapi version: 4.11.1
  • Database: postgres
  • Operating system: MacOS
  • Is your project Javascript or Typescript: Typescript

Describe the bug

Consider having a Collection Component named Product that is structured as follows:

{
    "name": "...",
    "price" : 100,
    "logo" : media attachment
}

Then, consider another Component named Category which has one-to-many relation with product.

Now, the Category has relations to two products, and when getting the results via Rest API, it shows the followings:

Expected behavior

The expected result should be as follows:

{
  "data": [
    {
      "attributes": {
        "name": "Category name",
        "products": {
          "data": [
            {
              "attributes": {
                "name": "Product 1",
                "price": 100,
                "logo": {
                  "data": {
                    "attributes": {
                      "url": "some/url"
                    }
                  }
                }
              }
            },
            {
              "attributes": {
                "name": "Product 2",
                "price": 100,
                "logo": {
                  "data": {
                    "attributes": {
                      "url": "some/url"
                    }
                  }
                }
              }
            }
          ]
        }
      }
    }
  ]
}

However, when setting a webhook to send the payload on publish (for example), it sends only the followings:

{
  "data": [
    {
      "attributes": {
        "name": "Category name",
        "products": {
          "data": [
            {
              "attributes": {
                "name": "Product 1",
                "price": 100
              }
            },
            {
              "attributes": {
                "name": "Product 2",
                "price": 100
              }
            }
          ]
        }
      }
    }
  ]
}

Totally ignoring the media component, or any other custom component for that matter.

Solutions that didn't work

I've tried to set the webhooks relations key in server.js as follows with no result:

webhooks: {
    populateRelations: true,
  },

Also, I've tried to set the performance to false as follows with no result:

relations: {
    performance: false,
  }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions