wp-graphql / wp-graphql-woocommerce

Add WooCommerce support and functionality to your WPGraphQL server
https://woographql.com
GNU General Public License v3.0
645 stars 130 forks source link

productCategories returns incorrect products of categories #890

Closed bkstorm closed 1 week ago

bkstorm commented 1 month ago

Describe the bug The list of products of a category is not correct.

To Reproduce Steps to reproduce the behavior:

  1. Create 2 categories: Category 1 and Category 2
  2. Create 2 products: Product 1 and Product 2
  3. Add Product 1 to the Category 1, Product 2 to the Category 2.
  4. Execute productCategories api.

Expected behavior Product 1 should belong to the Category 1, Product 2 should belong to the Category 2.

Actual behavior Product 1 belongs to both Category 1 and Category 2. Product 2 belongs to both Category 1 and Category 2.

Screenshots

Screenshot 2024-09-16 at 13 33 29 Screenshot 2024-09-16 at 13 33 50 Screenshot 2024-09-16 at 13 34 05 Screenshot 2024-09-16 at 13 34 48

Desktop (please complete the following information):

Plugin Versions

kidunot89 commented 1 month ago

@bkstorm Have you tried this with the latest version v0.21.x?

bkstorm commented 3 weeks ago

@bkstorm Have you tried this with the latest version v0.21.x?

I tried with v0.21, it did not work.

UPSxACE commented 3 weeks ago

Same problem. In v0.21.0 it does return some products right(apparently), but it doesn't return all of them, nor the pageInfo correctly. The plugin is unusable.

dominio50 commented 2 weeks ago

For some reason the products that you query from inside the productCategories type, requires you to still provide the categoryId(databaseId) in the where clause in the product query.

products(first: 12, after: $after, where: { categoryId: $databaseId, stockStatus: IN_STOCK, status: "PUBLISH" }) { }

dominio50 commented 2 weeks ago

For some reason the products that you query from inside the productCategories type, requires you to still provide the categoryId(databaseId) in the where clause in the product query.

products(first: 12, after: $after, where: { categoryId: $databaseId, stockStatus: IN_STOCK, status: "PUBLISH" }) { }

This seems to have been fixed in v0.21.0

bkstorm commented 1 week ago

I tried again with v0.21.0 today, and it works as expected. It seems like there is something wrong with my code, not wp-graphql, so I will close this issue. Thanks!