Skip to content
Open
Prev Previous commit
Next Next commit
modifying proposal
  • Loading branch information
cpartica committed Feb 5, 2021
commit 7a191b52f5bae6548595c268f6d9640a5cbc951a
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,62 @@ type CustomAttributeMetadata {
}

type Attribute {
uid: String
attribute_code: String
label: String
attribute_type: String @deprecated(reason: "use `attribute_data_type` instead")
attribute_data_type: ObjectDataType
entity_type: EntityType
input_type: UiInputType
sort_order: Int
metadata_values: [AttributeMetadataValue]
attribute_options: [AttributeOption]
attribute_type: String
entity_type: String
input_type: String
}

enum ObjectDataType {
STRING
FLOAT
INT
}

enum EntityType {
customer
customer_address
catalog_category
catalog_product
order
invoice
creditmemo
shipment
rma_item
}

enum UiInputType {
text
dropdown
swatch
file
multi_line
#....
}

enum MetadataType {
Values_Unique
Values_validation
#...
}

type AttributeMetadataValue {
label: String
values: [String]
metadata_type: MetadataType
}

type AttributeOption {
label: String
value: String
uid: ID!
value: String @deprecated(reason: "use `uid` instead")
label
is_default
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,50 @@ One workaround for "getting all fields" is based on schema introspection, it all

# Proposed solution

To account for dynamic nature of EAV attributes and the need of "getting all fields" in product search queries, we can introduce `custom_attributes: [CustomAttribute]!` container (recommended approach).
To account for dynamic nature of EAV attributes and the need of "getting all fields" in product search queries, we can introduce `stored_attributes: [StoredAttribute]!` container (recommended approach).
The container will return the list of attributes plus the actual values stored for each entity.

```graphql
type CustomAttribute {
code: String!
values: [String]! # We want to account fo attributes that have single (text, dropdown) and multiple values (checkbox, multiselect)
type StoredAttribute {
selected_attributes: [SelectedAttribute] # used to store unique options values
entered_attributes: [EnteredAttribute] # used to store the freetype entered values like texts
available_attributes: [Attribute] # metadata of the actual attribute not related to the stored Entity-Attribute value
}

type SelectedAttribute {
attribute: Attribute # existing type for metadata
options_uids: [ID]
}

type EnteredAttribute {
attribute: Attribute # existing type for metadata
value: String
}
```

We could also make value complex type to be able add more fields in the future, but this doesn't seem necessary at this point.
We could also make value complex type to be able add more complex fields values in the future, but this doesn't seem necessary at this point.
This is also aligned with the Selected, Entered values from customizable options, or configurable product.

Alternative approach would be is to introduce a type or an interface `custom_attributes: [CustomAttribute]!`.

```graphql
type CustomAttribute {
code: String!
values: [CustomAttributeValue]!
}

type CustomAttributeValue {
value: String!
values: [String]! # We want to account fo attributes that have single (text, dropdown) and multiple values (checkbox, multiselect)
}
```

Alternative approach would be is to introduce an interface `custom_attributes: [CustomAttributeInterface]!`, but it seems more complicated.
Or to introduce a type or an interface `custom_attributes: [CustomAttributeInterface]!`, but it seems more complicated.

```graphql
type CustomAttributeInterface {
interface CustomAttributeInterface {
code: String!
}

type SingleValueCustomAttribute extends CustomAttributeInterface {
type SingleValueCustomAttribute implements CustomAttributeInterface {
value: String!
}

type MultipleValuesCustomAttribute extends CustomAttributeInterface {
type MultipleValuesCustomAttribute implements CustomAttributeInterface {
values: [String]!
}
```
Expand Down Expand Up @@ -71,7 +81,7 @@ Current implementation allows the following query

Let's assume the response will be

```graphql
```json
{
"data": {
"products": {
Expand Down Expand Up @@ -114,7 +124,7 @@ With the proposed changes the above mentioned queries will still be supported. I
```
Note that color and size are not applicable to some products in the search result. In the previous example they were returned as `null`. In the following example they are not returned at all

```graphql
```json
{
"data": {
"products": {
Expand Down