wp-graphql-woocommerce
wp-graphql-woocommerce copied to clipboard
Getting Same product list when pegination
Describe the bug I am trying to query the product list with sort by price and categoryId. but after I call the next page by adding endCursor it seems to be getting the same product on the next page. each pagination request is getting the same product list.
I am using this query:
query GetProducts($featured: Boolean, $attribute: String, $attributeTerm: String, $categoryId: Int, $search: String, $sort: [ProductsOrderbyInput], $after: String, $taxFilter: [ProductTaxonomyFilterInput], $type: ProductTypesEnum, $sellerId: ID, $shuffle: Boolean, $onlyActiveAuction: Boolean, $categoryIdIn: [Int], $first: Int) {
products(where: {attributeTerm: $attributeTerm, attribute: $attribute, categoryId: $categoryId, search: $search, orderby: $sort, taxonomyFilter: {and: $taxFilter}, featured: $featured, type: $type, sellerId: $sellerId, shuffle: $shuffle, onlyActiveAuction: $onlyActiveAuction, categoryIdIn: $categoryIdIn}, after: $after, first: $first) {
nodes {
image {
sourceUrl(size: THUMBNAIL)
}
date
featured
name
onSale
id
databaseId
... on SimpleProduct {
id
name
price
salePrice
onSale
regularPrice
}
shortDescription(format: RAW)
... on VariableProduct {
id
name
variations {
nodes {
price
salePrice
regularPrice
name
onSale
}
}
price
}
... on AuctionProduct {
id
name
databaseId
price
regularPrice
startPrice
reservedPrice
}
type
}
pageInfo {
endCursor
hasNextPage
}
}
}
Using this query variables :
{
"sort": [{
"field": "PRICE",
"order": "ASC"
}],
"first": 20,
"after": "YXJyYXljb25uZWN0aW9uOjM0MTk4",
"categoryId": 277
}
Using this query, whenever I call the second page by adding endCursor I'm getting the same product list.
@akshaykatale99 I ran into this issue a while back when trying to sort by price. You may want to look at my PR and see if that filter we've added helps with your price meta issue.
https://github.com/wp-graphql/wp-graphql/pull/1546
I am running into the same issue. It seems to happen only when I am using orderBy as filter on a products query:
query Products($after: String, $before: String, $first: Int, $last: Int, $where: RootQueryToProductConnectionWhereArgs) {
products(
after: $after
before: $before
first: $first
last: $last
where: $where
) {
nodes {
__typename
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
}
Example variables
{
"first": 24,
"after": "YXJyYXljb25uZWN0aW9uOjE5MTM5",
"where": {
"orderby": [
{
"field": "MENU_ORDER",
"order": "ASC"
}
],
"status": "publish",
"visibility": "VISIBLE"
}
}
If I remove orderBy the pagination seems working correctly
{
"first": 24,
"after": "YXJyYXljb25uZWN0aW9uOjE5MTM5",
"where": {
"status": "publish",
"visibility": "VISIBLE"
}
}
I am using the following version
"wp-graphql/wp-graphql": "1.6.11",
"wp-graphql/wp-graphql-woocommerce": "0.10.6"
This issue was resolved in v0.12.1