Maybe I'm doing something wrong or maybe this is a problem with wp-graphql-woocommerce but cursor pagination seems broken. I'm using the latest version of wp-graphql (v1.3.5). My query looks something like this:
query GetProducts {
products(
first: 4,
after: ""
) {
edges {
node {
name
}
}
pageInfo {
endCursor
hasNextPage
}
}
}
The first time I run this (with an empty or null endCursor) I get products back and I get a new endCursor. However, if I use the returned endCursor by inserting it in after and rerun the query I get no results.
Oddly, if I then change the number of products I want returned by setting first to some other value it suddenly works again.
@PaperPlaneSoftware are you using WPGraphQL for WooCommerce or are products a Custom Post Type you registered to show in WPGraphQL on your own?
Can you provide enough information for us to reproduce?
What plugins you have active, how many products you have and details about them, etc. Possibly even an export of Products we could import, etc.
The more information we have to reproduce the issue in a local dev environment, the better we can help identify and fix issues.
@jasonbahl Yes I'm using WPGraphQL for WooCommerce (specifically version 0.7.0). I'll try the latest version (0.8.1 I think) tomorrow to see if that resolve the issue.
Other plugins I have active are WPGraphiQL (1.0.1), WPGraphQL CORS (1.1.0), WPGraphQL JWT (0.4.0), WPGraphQL for ACF (0.4.0) and WPGraphQL Offset Pagination (0.2.0) but it's deactivted.
Are there any specific log files I could dump in here?
I updated to WPGraphQL-WooCommerce 0.8.1 but the same thing is happening.
I also tried the same thing using posts rather than products and it works fine, so I'm guessing this is an issue specifically with WPGraphQL-WooCommerce.
I believe @kidunot89 is working on changing how Product Connections resolve to make more use of some of the internal WPGraphQL connection resolvers. I'm not sure the progress/ETA on that, but that might end up solving this issue when that change is complete.
I'll transfer this issue to that repo to track over there.
Came here to report the same issue. Rolling back WPGraphQL to v1.2.5 fixed the problem for me. I thought it might be related to the pagination fix that came out in 1.3.4, but the problem persisted even after I rolled back to 1.3.3.
Came here to report the same issue. Rolling back WPGraphQL to v1.2.5 fixed the problem for me. I thought it might be related to the pagination fix that came out in 1.3.4, but the problem persisted even after I rolled back to 1.3.3.
That worked for me also.
Although v1.2.5 doesn't have the pagination bug, it has another (even worse problem), it periodically crashes my WP server. I noticed that rerunning certain GQL queries causes the server to crash (or it might be the DB that's crashing, I'm not quite sure) and I have to wait for it to restart.
v1.2.6 Is exactly the same.
v1.3.0 is completely unstable. My server constantly crashes so I'm not sure if the pagination bug exists in that version or not.
v1.3.1 is the first version in which the pagination bug appears. But it also seems to resolve whatever was causing my server to crash in the previous versions.
@kidunot89 do you need some help on this issue? Any pointers to where the problem may be?
@PaperPlaneSoftware, thanks for reporting this. Also reproduced this behavior, and rolling back WPGraphQL to v1.2.5 did indeed work.
However, still faced an issue with fewer products than expected being returned. This seemed somewhat related to the visibility and published status of the product, e.g. private products wouldn't show up in the results but would "occupy" one of the result slots. Changing the product's status from private to published yielded expected results. However, some private products did show up in the result set, so this isn't a consistent error.
In any case: should anyone else run into this problem, a workaround is to filter out unpublished and hidden products by using a where parameter. This worked for me; YMMV.
Example (expanding on PaperPlaneSoftware's example):
query GetProducts {
products(
first: 4,
after: "",
where: {
"status": "publish",
"visibility": "VISIBLE"
}
) {
edges {
node {
name
}
}
pageInfo {
endCursor
hasNextPage
}
}
}
(WPGraphQL 1.2.5, WooGraphQL 0.8.1, WooGraphQL Product Bundles 0.0.4)
Most helpful comment
Came here to report the same issue. Rolling back WPGraphQL to v1.2.5 fixed the problem for me. I thought it might be related to the pagination fix that came out in 1.3.4, but the problem persisted even after I rolled back to 1.3.3.