【问题标题】:How to add orderBy directive to relationship in a query?如何将 orderBy 指令添加到查询中的关系?
【发布时间】:2022-03-07 20:50:44
【问题描述】:

我有这个:

type Client @guard {
  id: ID!
  name: String!
  phone: String
  orders: [Order!]! @hasMany # How do i make it possible to order this array via client side?
}
extend type Query {
  client (
    id: ID! @eq
  ): Client @find
}

我想做这样的事情:

{
  client (id: 10) {
    orders (orderBy: ....) {
    }
  }
}

我已经尝试在orders 字段上添加@orderBy,但它似乎不起作用,是否可以在 lighthouse-php 中进行?

【问题讨论】:

    标签: laravel-lighthouse


    【解决方案1】:

    @orderBy 指令让您指定一个关系,您可以从中订购查询。 See the documentation

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
    猜你喜欢
    • 2019-07-17
    • 1970-01-01
    • 1970-01-01
    • 2019-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多