|
| 1 | +# Remove product dynamic attributes from ProductInterface |
| 2 | + |
| 3 | +## Current state |
| 4 | + |
| 5 | +Currently, Magento exposes EAV attributes as part of the product schema as top-level fields of ProductInterface. As consequences: |
| 6 | +* The merchant can change the GraphQL from the admin, which makes it hard to cache GraphQL schema. |
| 7 | +* Regular product interface overloaded with fields and almost unreadable. |
| 8 | +* It is quite often practice to create product programmatically, so the number of attributes could be really excessive with tens thousands of attributes. |
| 9 | +* Two Magento instances do not have the same GraphQL schema. As a result, it is near impossible to build a simple client/SDK, which could be easily transferred from one instance to another. |
| 10 | +* It is impossible to aggregate the several Magento instances behind the common [BFF](https://docs.microsoft.com/en-us/azure/architecture/patterns/backends-for-frontends). |
| 11 | + |
| 12 | +## Proposed solution |
| 13 | + |
| 14 | +We should to remove attributes dynamic attributes, |
| 15 | +except system attributes which makes sense for the storefront, |
| 16 | +from the product top level and use a [dynamic container](https://github.com/magento/architecture/blob/master/design-documents/graph-ql/custom-attributes-container.md) instead. |
| 17 | + |
| 18 | + |
| 19 | +```graphql |
| 20 | +## ProductInteface with system EAV attributes |
| 21 | +type ProductInterface { |
| 22 | + uid: ID |
| 23 | + name: String |
| 24 | + sku: String |
| 25 | + attribute_set_id: Int |
| 26 | + description: ComplexTextValue |
| 27 | + short_description: ComplexTextValue |
| 28 | + meta_title: String |
| 29 | + meta_keyword: String |
| 30 | + meta_description: String |
| 31 | + created_at: String |
| 32 | + updated_at: String |
| 33 | + custom_attributes: [CustomAttribute] |
| 34 | + ... |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +## System EAV attributes that should be deprecated at the storefront |
| 39 | + |
| 40 | +* `special_price: Float` These fields should not be used a the source of the discount since the discount also could be caused by group price or rule price, which are not reflected in this field. |
| 41 | +The same is true for `special_from_date: String` and `special_to_date`. |
| 42 | + |
| 43 | +* `options_container: String` - this field just an exposure of `catalog_product_entity` table field, information about product options could be explicitly retrieved from the corresponding field. |
| 44 | +* `manufacturer: Int` - just a sample attribute from Magento 1.x, we can move it to the custom attributes container. |
| 45 | +the same is true for `country_of_manufacture: String` |
0 commit comments