Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Edges is empty but pageInfo is telling hasNextPage: true #947

Closed
RobinKemna opened this issue Jul 21, 2023 · 6 comments
Closed

Edges is empty but pageInfo is telling hasNextPage: true #947

RobinKemna opened this issue Jul 21, 2023 · 6 comments
Labels

Comments

@RobinKemna
Copy link

RobinKemna commented Jul 21, 2023

Issue summary

We run a custom Shopify app that uses the graphql client from this package. When querying for orders with "financial_status:paid AND (fulfillment_status:unfulfilled OR fulfillment_status:partially_fulfilled) AND -status:closed" we receive an empty edges object, but pageInfo says it has a nextPage. For some reason the query response does not contain any orders. BUT if we run the query from e.g. postman (with same access token) or graphiql in the same store, we receive results. Thus we assume that it has something to do with the library and would love to get some support on it.

The actual query:


        orders(first: 5, query: "financial_status:paid AND (fulfillment_status:unfulfilled OR fulfillment_status:partially_fulfilled) AND -status:closed") {
            edges {
                node {
                    createdAt
                    id
                    name
                }
            }
            pageInfo {
                endCursor
                startCursor
                hasNextPage
                hasPreviousPage
            }
        }

Screenshot of the response logged from our application:
image

  • @shopify/shopify-api version: 7.5.0
  • Node version: 18.17.0 LTS
  • Operating system: Heroku / Linux

Expected behavior

We would expect that the edges property actually contains the orders, same as the postman response does.

Actual behavior

edges is empty and hasNextPage is true.

Steps to reproduce the problem

  1. create an app
  2. instanciate a gql client by the package
  3. make a request as described above
@RobinKemna
Copy link
Author

Some more details:

If we send the request, using postman with raw body as JSON, we can see the same issue as the library has:

image

And if we use the Graphql Option in postman, we receive the proper results:
image

@RobinKemna
Copy link
Author

This issue seems to be related to some shopify internal stuff rather than this library.

If we increase the number of fetched orders to a higher amount, also the raw query and the library it self does respond with proper results. But it seems that the orders list is empty cause it tries to first pick the defined number of results from all orders and than filters them by the defined query.

Internally it might be something like:

const orders = [1,2,3,4,5,6,7,8,9]

const definedFirstElements = orders.slice(0, <first>);

const response = definedFirstElements.filter(yourQueryString);

which can result in an empty response.
And hasPageNext ist calculated on orders.length...

I will open a ticket at shopify directly for that..

@paulomarg could you maybe push that topic internally as it seems to be a bug at shopifys query logic...
It makes it impossible e.g. to build a proper pagination view of a query result.

@github-actions
Copy link
Contributor

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

@github-actions github-actions bot added the Stale label Sep 20, 2023
@Axel29
Copy link

Axel29 commented Sep 22, 2023

Had the same issue yesterday with a GraphQL Query (see bellow).
I noticed that adding the "reverse: true" option makes it work again, so my guess is that there's one (or several) order(s) that break the request.
Because of that, I'm guessing that at some point, it would be broken on a specific page again, so this is probably not a real fix.

Query:

{
    orders(first: 25, query: "-tag:'erp.exported' AND (fulfillment_status:unshipped OR fulfillment_status:partial) AND financial_status:paid") {
        edges {
            cursor
            node {
                id
                name
                updatedAt
                fulfillmentOrders(
                    first: 1
                    query: "assigned_location_id:XXXXXXXXXXX AND -status:closed"
                ) {
                    edges {
                        cursor
                        node {
                            id
                            status
                            lineItems(first: 20) {
                                nodes {
                                    id
                                    sku
                                    totalQuantity
                                    remainingQuantity
                                }
                            }
                        }
                    }
                    pageInfo {
                        startCursor
                        endCursor
                        hasNextPage
                        hasPreviousPage
                    }
                }
            }
        }
        pageInfo {
                        startCursor
                        endCursor
            hasNextPage
            hasPreviousPage
        }
    }
}

@github-actions github-actions bot removed the Stale label Sep 23, 2023
Copy link
Contributor

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

@github-actions github-actions bot added the Stale label Nov 23, 2023
Copy link
Contributor

github-actions bot commented Dec 7, 2023

We are closing this issue because it has been inactive for a few months.
This probably means that it is not reproducible or it has been fixed in a newer version.
If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.

If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines

Thank you!

@github-actions github-actions bot closed this as completed Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants