Skip to content

GraphQL custom attributes container proposal #282

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

Conversation

paliarush
Copy link
Contributor

GraphQL custom attributes containers proposal

@paliarush paliarush self-assigned this Sep 18, 2019
@paliarush paliarush mentioned this pull request Sep 18, 2019
@AlexMaxHorkun
Copy link
Contributor

Different products having different set of properties (custom attributes) sounds a lot like products having different interfaces and GraphQL has tools for clients to request certain fields based on data type/interface. I think that we could generate interfaces based on Attribute Sets so that clients could do something like this:

products (filter: $filter) {
    items {
        sku
        ... on AttrSetDefaultProductInterface {
            color
        }
        ... on AttrSetCustomSimpleProduct {
            custom_attr
        }
    }

That would be a more elegant and GraphQL compliant solution then duplicating bunch of fields as custom_attributes list. @paliarush what do you think?

@paliarush
Copy link
Contributor Author

@AlexMaxHorkun unfortunately multiple interfaces do not solve the issue described in the proposal: the client will still have to list all possible fields, even worse, now the client will have to list all known attribute sets as well. In addition, knowledge about attribute sets is admin-only.

@AlexMaxHorkun
Copy link
Contributor

@AlexMaxHorkun unfortunately multiple interfaces do not solve the issue described in the proposal: the client will still have to list all possible fields, even worse, now the client will have to list all known attribute sets as well. In addition, knowledge about attribute sets is admin-only.

Clients are probably aware of all the fields - they'd have to display them after all. I still think products of different sets can be treated as basically different product classes - they posses different properties and most likes differ in presentation.

@AlexMaxHorkun
Copy link
Contributor

@paliarush Have you considered introducing a new Query with custom attributes and their metadata for clients to utilize when querying products? Clients might want to display attributes differently based on their type and frontend label etc. I think that would solve this issue. Perhaps such query already exists, I haven't checked

@paliarush
Copy link
Contributor Author

@AlexMaxHorkun There is metadata query and there is a plan to add attribute metadata to schema.
I think we are not on the same page regarding the issue being solved here.
Example: client has to send query with 10000 attributes during product search. In the response it gets products with 100 different attribute values and 9900 nulls per product. This is an issue and I don't see how it is solved with your proposal.

@buskamuza buskamuza merged commit be534c3 into magento:master Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants