-
Notifications
You must be signed in to change notification settings - Fork 152
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
Update proposal for custom attributes schema #456
Open
melnikovi
wants to merge
12
commits into
magento:master
Choose a base branch
from
magento-honey-badgers:custom-attributes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
11be876
Update custom attributes container proposal to account for attributes…
melnikovi 72a2238
Update custom attributes container proposal to account for attributes…
melnikovi 3205dd0
Update custom attributes container proposal to account for attributes…
melnikovi 7a191b5
modifying proposal
cpartica c12eb3e
adding interfaces on inputs
cpartica c711235
refactor some things on product attributes
cpartica 763fd6d
- refactor options
cpartica c2d29e2
- reactor types
cpartica 27243fb
- refactor container explanation
cpartica 49ed712
- rename option ids
cpartica 74fd87e
refactoring to simplify query and schema
cpartica b365474
refactoring to simplify query and schema
cpartica File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,42 @@ 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, `custom_attributes: [CustomAttribute]!` container will be introduced. | ||
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. | ||
|
||
```graphql | ||
type CustomAttribute { | ||
code: String! | ||
values: [String]! # We want to account fo attributes that have single (text, dropdown) and multiple values (checkbox, multiselect) | ||
} | ||
``` | ||
|
||
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. | ||
|
||
```graphql | ||
type CustomAttribute { | ||
code: String! | ||
values: [CustomAttributeValue]! | ||
} | ||
|
||
type CustomAttributeValue { | ||
value: String! | ||
} | ||
``` | ||
|
||
Alternative approach would be is to introduce an interface `custom_attributes: [CustomAttributeInterface]!`. | ||
|
||
```graphql | ||
type CustomAttributeInterface { | ||
code: String! | ||
} | ||
|
||
type SingleValueCustomAttribute extends CustomAttributeInterface { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. even if this adds more complexity, it's the graphql way to do it and I prefer it |
||
value: String! | ||
} | ||
|
||
type MultipleValuesCustomAttribute extends CustomAttributeInterface { | ||
values: [String]! | ||
} | ||
``` | ||
|
||
Here `value` is JSON-encoded value of the custom attribute. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have to add "type" opinion here to be able to render the appropriate template (datetime, text, multi-select, checkbox ...)
E.g.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attributes are going to be displayed as information and not as fields you can control, so I don't think it's necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will be useful to render field properly on UI without complex logic. E.g. for "Date" field - "10-11-2020"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, they are needed for the forms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have this data already available in the scope of
customAttributeMetadata
query. Since update frequency for attribute metadata and product attribute values is different, it makes sense to separate them to avoid excessive payload size.