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

Support of custom attributes values for entities like customer/product/address #458

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Attribute {
attribute_type: String
entity_type: String
input_type: String
is_required: Bolean!
}

type AttributeOption {
Expand Down
13 changes: 11 additions & 2 deletions design-documents/graph-ql/coverage/customer/customer.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ input CustomerAddressInput {
prefix: String @doc(description: "An honorific, such as Dr., Mr., or Mrs.")
suffix: String @doc(description: "A value such as Sr., Jr., or III")
vat_id: String @doc(description: "The customer's Tax/VAT number (for corporate customers)")
custom_attributes: [CustomerAddressAttributeInput] @doc(description: "Deprecated: Custom attributes should not be put into container.")
custom_attributes: [CustomerAddressAttributeInput] @deprecated(reason: "Use custom_attributes_v2.")
custom_attributes_v2: [CustomAttributeInput] @doc(description: "Custom attributes.")
}

input CustomerAddressRegionInput @doc(description: "CustomerAddressRegionInput defines the customer's state or province") {
Expand All @@ -59,6 +60,11 @@ input CustomerAddressAttributeInput {
value: String! @doc(description: "Attribute value")
}

input CustomAttributeInput {
attribute_code: String! @doc(description: "Code.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to uid

values: [String]! @doc(description: "Values.")
}

type CustomerToken {
token: String @doc(description: "The customer token")
}
Expand All @@ -76,6 +82,7 @@ input CustomerInput {
gender: Int @doc(description: "The customer's gender (Male - 1, Female - 2)")
password: String @doc(description: "The customer's password")
is_subscribed: Boolean @doc(description: "Indicates whether the customer is subscribed to the company's newsletter")
custom_attributes: [CustomAttributeInput] @doc(description: "Custom attributes.")
}

type CustomerOutput {
Expand Down Expand Up @@ -104,6 +111,7 @@ type Customer @doc(description: "Customer defines the customer name and address
is_subscribed: Boolean @doc(description: "Indicates whether the customer is subscribed to the company's newsletter") @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\IsSubscribed")
addresses: [CustomerAddress] @doc(description: "An array containing the customer's shipping and billing addresses") @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\CustomerAddresses")
gender: Int @doc(description: "The customer's gender (Male - 1, Female - 2)")
custom_attributes: [CustomAttribute]!
}

type CustomerAddress @doc(description: "CustomerAddress contains detailed information about a customer's billing and shipping addresses"){
Expand All @@ -128,7 +136,8 @@ type CustomerAddress @doc(description: "CustomerAddress contains detailed inform
vat_id: String @doc(description: "The customer's Value-added tax (VAT) number (for corporate customers)")
default_shipping: Boolean @doc(description: "Indicates whether the address is the default shipping address")
default_billing: Boolean @doc(description: "Indicates whether the address is the default billing address")
custom_attributes: [CustomerAddressAttribute] @deprecated(reason: "Custom attributes should not be put into container")
custom_attributes: [CustomerAddressAttribute] @deprecated(reason: "Use custom_attributes_v2 field.")
custom_attributes_v2: [CustomAttribute]! @doc(description: "Custom attributes.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this array CAN be empty, but we always have to return an array if no attribute are defined

CustomAttribute doesn't contain the same amount of data as Attribute from EAV
Eav includes CustomAttribute. Complex Eav values could be expressed as JSON like tier price

We need to show both pieces of information to avoid a round trip to customAttributeMetadata

  • selected_options/entered_options
  • the whole info from customAttributeMetadata on each available attribute

`stored_attributes_v2: [StoredAttribute]

type StoredAttribute {
atttribute_uid
selected_attribute_values: [ID]
entered_attribute_values: [String]
attributes: [Attribute]
}
`

extension_attributes: [CustomerAddressAttribute] @doc(description: "Address extension attributes")
}

Expand Down
2 changes: 1 addition & 1 deletion design-documents/graph-ql/coverage/returns.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ type ReturnItem {
type CustomAttribute {
uid: ID!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably have to deprecte this in favor of CustomAttributeV2

label: String!
value: String! @doc(description: "JSON encoded value of the attribute.")
values: [String]! @doc(description: "JSON encoded value of the attribute.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this defined on the returns. this belongs in the EAV module

}

type ReturnComment {
Expand Down