Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] repeatable component with nested component that contains a relation is not transformed #99

Open
yarkovaleksei opened this issue Jan 27, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@yarkovaleksei
Copy link

yarkovaleksei commented Jan 27, 2024

transformer: {
  enabled: true,
  config: {
    responseTransforms: {
      removeAttributesKey: true,
      removeDataKey: true,
    },
    requestTransforms : {
      wrapBodyWithDataKey: true,
    },
  },
}

image

image

Relation type "oneToOne".

Response example:

{
  "size": [ // Component "size"
    {
      "id": 1,
      "length": 90,
      "width": 60,
      "height": 5,
      "price": 15000,
      "stand": { // Nested component "size.stand"
        "id": 1,
        "additionalProducts": { // Relation field (oneToOne)
          "data": { // not deleted
            "id": 3,
            "attributes": { // not deleted
              "title": "Тумба 70x20x20",
              "description": "Описание тумбы 70x20x20",
              "price": 2000,
              "createdAt": "2024-01-06T11:30:46.980Z",
              "updatedAt": "2024-01-06T11:30:49.477Z",
              "publishedAt": "2024-01-06T11:30:49.384Z",
              "locale": "ru"
            }
          }
        }
      }
    }
  ]
}
@ComfortablyCoding
Copy link
Contributor

ComfortablyCoding commented Jan 28, 2024

I cannot reproduce this issue on the latest strapi version with the provided information. The data is transformed correctly with the data and attributes keys removed.

Can you provide the full schema files for all related content types/components? This should make it easier to reproduce.

@yarkovaleksei
Copy link
Author

// src/api/memorial/content-types/memorial/schema.json
{
  "kind": "collectionType",
  "collectionName": "memorials",
  "info": {
    "singularName": "memorial",
    "pluralName": "memorials",
    "displayName": "Memorials",
    "description": ""
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "title": {
      "type": "string",
      "required": true
    },
    "size": {
      "type": "component",
      "repeatable": true,
      "component": "record.razmer-s-fiksirovannoj-czenoj-3-d", // component with nested component
      "required": true
    }
  }
}
// src/api/additional-product/content-types/additional-product/schema.json
{
  "kind": "collectionType",
  "collectionName": "additional_products",
  "info": {
    "singularName": "additional-product",
    "pluralName": "additional-products",
    "displayName": "Additional products",
    "description": ""
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "title": {
      "type": "string",
      "required": true
    }
  }
}
// src/components/record/razmer-s-fiksirovannoj-czenoj-3-d.json
{
  "collectionName": "components_record_razmer_s_fiksirovannoj_czenoj_3_ds",
  "info": {
    "displayName": "Memorial size",
    "description": ""
  },
  "options": {},
  "attributes": {
    "length": {
      "type": "integer",
      "required": true,
      "min": 0
    },
    "width": {
      "type": "integer",
      "required": true,
      "min": 0
    },
    "height": {
      "type": "integer",
      "required": true,
      "min": 0
    },
    "price": {
      "type": "decimal",
      "required": true,
      "min": 0
    },
    "additionalProducts": {
      "type": "component",
      "repeatable": false,
      "component": "memorial.obyazatelnye-dop-tovary", // problem nested component
      "required": true
    }
  }
}
// src/components/memorial/obyazatelnye-dop-tovary.json
{
  "collectionName": "components_memorial_obyazatelnye_dop_tovary",
  "info": {
    "displayName": "Required additional products"
  },
  "options": {},
  "attributes": {
    "stand": {
      "type": "relation",
      "relation": "oneToOne",
      "target": "api::additional-product.additional-product" // Objects from this collection not transformed
    }
  }
}

@ComfortablyCoding ComfortablyCoding added the bug Something isn't working label Jan 30, 2024
@ComfortablyCoding
Copy link
Contributor

Thanks for the schema! I was able to reproduce this issue and will look into fixing it.

@ComfortablyCoding ComfortablyCoding changed the title Data and attributes inside relations in a component field are not deleted [BUG] repeatable component with nested component that contains a relation is not transformed Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants