GraphQL Order filtering

Solved
HunkyBill
Shopify Expert
4369 36 463

Frustration.

 

So once again. Help me out. Simple GraphQL. Give me open orders so I can deal with them.

 

    orders(first: $numOrders, after: $cursor, query:"status:open") {

 

This does not work. Apparently, we cannot filter orders yet. What is the point of pushing us to GraphQL if we cannot even use it for the most basic of requests?

 

Any hot tips on how to get at open orders?

 

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
hassain
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 134

Hey @HunkyBill ,

 

That is super strange you are seeing this not working. I just tried this query out on my test store with version 2020-04 right now and successfully only got the first 100 "Open" status orders in my store as the response:

 

query {
  orders(first: 100, query:"status:open") {
    edges {
      node {
        id
        name
        displayFinancialStatus
        displayFulfillmentStatus
        closedAt
      }
    }
  }
}

 If you are still seeing this issue, mind sending me the value of the X-Request-ID response header from the Shopify GraphQL Admin API response so I can take a deeper look in our logs to see what happened here?

 

Also I am sure you are probably already aware, but one thing to remember whenever you are querying orders from the Admin API is that unless your app has the scope approved of 'read_all_orders', you're only going to get the last 60 days of orders made available to you in your query results. 

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
HunkyBill
Shopify Expert
4369 36 463

I get results, but the response contains errors. So in this case the query of

 

    orders(first: $numOrders, after: $cursor, query:"status:open")    returns $numOrders... and one error message per edge. Here is a request ID for you:

 

    a4d5c3b8-8f0d-401b-8952-d0d3722c42c9

 

   

                  "node": {
                    "id": "gid:\/\/shopify\/LineItem\/4886280503432",
                    "title": "My Pretty Vampire",
                    "name": "My Pretty Vampire - Hardback",
                    "quantity": 1,
                    "sku": "9781683960201",
                    "originalTotalSet": {
                      "presentmentMoney": {
                        "amount": "19.99"
                      }
                    }
                  }
                }
              ]
            }
          }
        }
      ]
    }
  },
  "errors": [
    {
      "message": "access denied",
      "locations": [
        {
          "line": 12,
          "column": 9
        }
      ],
      "path": [
        "orders",
        "edges",
        0,
        "node",
        "customer"
      ]
    },

 

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
hassain
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 134

This is an accepted solution.

Hey @HunkyBill ,

 

Thanks for the Request-ID and the additional information, super useful!

 

Based on what I can see from our platform logs, and from the error message you provided, the error you got is because your app was denied access to the property of "orders[0].customer".

 

Just to ask the obvious question, can you confirm that your app does have the access scope of "read_customers" enabled? If not, that might explain why you are getting results for the order data but getting error messages when trying to access customer data within the orders.  If you do have this scope enabled, I'll have to investigate more as to why you are seeing this error. 

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

HunkyBill
Shopify Expert
4369 36 463

No, the App did not have that scope. I will add it in and see what happens! Thanks for the hot tip. It is not obvious that when one needs to process orders, that you need to scope customer access. That never used to be a thing, hence my oversight on that.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
HunkyBill
Shopify Expert
4369 36 463

Bingo. No more of those errors. Just a plea to have the actual errors surfaced better, please. Would be so much more helpful.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes