We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug A product attribute is returning all data when a given product is not associated with it instead of null.
null
I think the issue lies in our resolver when we are setting the values of wc_get_object_terms() to the query args.
wc_get_object_terms()
Perhaps we should return early if those $term_ids return empty instead of setting the query args to an empty array?
$term_ids
To reproduce Run the following query, where product with id 123 does not have the Sizes product attribute associated with it and only has Colors.
123
Sizes
Colors
{ product(id:123 idType: DATABASE_ID) { id paSizes { nodes { name } } paColors { nodes { name } } } }
Expected behavior paSizes should return null because the given product doesn't have any sizes.
paSizes
{ "data": { "product": { "id": "cHJvZHVjdDo0OTYwNzE=", "paSizes": null, "paColors": { "nodes": [ { "name": "Blue" }, { "name": "Maroon" } ] } } } }
Actual behavior paSizes returns the first 10 sizes.
{ "data": { "product": { "id": "cHJvZHVjdDo0OTYwNzE=", "paSizes": { "nodes": [ { "name": "W2XL" }, { "name": "W2XS" }, { "name": "W3XS" }, { "name": "WLG" }, { "name": "WMD" }, { "name": "WSM" }, { "name": "WXL" }, { "name": "WXS" } ] }, "paColors": { "nodes": [ { "name": "Blue" }, { "name": "Maroon" } ] } } } }
The text was updated successfully, but these errors were encountered:
Guard against empty terms
53cd35b
Addresses wp-graphql#372, which prevents returning all data for a given taxonomy when it's not associated with a product.
No branches or pull requests
Describe the bug
A product attribute is returning all data when a given product is not associated with it instead of
null
.I think the issue lies in our resolver when we are setting the values of
wc_get_object_terms()
to the query args.Perhaps we should return early if those
$term_ids
return empty instead of setting the query args to an empty array?To reproduce
Run the following query, where product with id
123
does not have theSizes
product attribute associated with it and only hasColors
.Expected behavior
paSizes
should returnnull
because the given product doesn't have any sizes.Actual behavior
paSizes
returns the first 10 sizes.The text was updated successfully, but these errors were encountered: