Graphql 错误:“不支持使用 last 而 before 不支持”

Non*_*Non 7 javascript shopify ecmascript-6 graphql

我正在使用 Gatsby + GraphQL + Shopify。我在检索最后 10 个订单时遇到问题。

我的查询如下所示:

query {
   customer(customerAccessToken: "${customerAccessToken}") {
      orders(last: 10) {...}
   }
}
Run Code Online (Sandbox Code Playgroud)

它返回这个:

"message": "不支持使用 last 而 before 不支持"

我注意到这个问题发生在其他一些开发者身上:https : //community.shopify.com/c/Shopify-Discussion/How-to-get-customer-s-orders-and-sort-by-date-in-descending/ mp/629133/highlight/false#M151241

如果您检查文档也没有提到使用beforelasthttps://shopify.dev/docs/admin-api/graphql/reference/object/order?api[version]=2020-07

底部有一个操场,您可以在其中测试查询。

其他人以前见过这个问题吗?

xad*_*adm 6

只需使用reversefirst

{
  orders(first: 10, reverse:true) {
    edges {
      node {
        id
        createdAt
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

  • 你好,但是 `first:10,verse:true` 不等于 `last:10`,假设你有 20 个数据 `[1,2,3....17,18,19,20]` 第一种方法将返回“[10,9,8,7...3,2,1]”,而第二个将返回“[20,19,18....12,11,10]”。 (2认同)