【问题标题】:GraphQL - Laravel - OrderBy by defaultGraphQL - Laravel - 默认为 OrderBy
【发布时间】:2021-09-08 05:12:38
【问题描述】:

我正在为 laravel 运行 lighthouse,但默认情况下它不起作用 @orderBy(没有传递参数)。

我遵循该指南,

https://lighthouse-php.com/master/api-reference/directives.html#orderby

预定义顺序 要为您的字段预定义默认顺序,请使用 这个指令在一个字段上:

type Query {   latestUsers: [User!]! @all @orderBy(column: "created_at", direction: DESC) } 

默认情况下,客户端无需向字段传递任何参数,仍会收到有序结果

而且不工作,只是从 1 到 10 排序

{
  "data": {
    "latestUsers": [
      {
        "id": "1",
        "createdAt": "2021-06-22 18:35:13"
      },
      {
        "id": "2",
        "createdAt": "2021-06-22 18:35:13"
      },
      {
        "id": "3",
        "createdAt": "2021-06-22 18:35:13"
      },.....

我用:

Checking platform requirements for packages in the vendor dir
ext-ctype      7.4.19      success  
ext-date       7.4.19      success
ext-dom        20031129    success
ext-fileinfo   7.4.19      success
ext-filter     7.4.19      success
ext-gd         7.4.19      success
ext-hash       7.4.19      success
ext-iconv      7.4.19      success
ext-json       7.4.19      success
ext-libxml     7.4.19      success
ext-mbstring   7.4.19      success
ext-openssl    7.4.19      success
ext-pcre       7.4.19      success
ext-phar       7.4.19      success
ext-simplexml  7.4.19      success
ext-spl        7.4.19      success
ext-tokenizer  7.4.19      success
ext-xml        7.4.19      success
ext-xmlreader  7.4.19      success
ext-xmlwriter  7.4.19      success
ext-zip        1.15.6      success
ext-zlib       7.4.19      success
lib-pcre       10.35       success
php            7.4.19      success

【问题讨论】:

    标签: laravel graphql laravel-lighthouse


    【解决方案1】:

    您必须确保至少在 Lighthouse v5.1.0 上运行。

    【讨论】:

      猜你喜欢
      • 2014-01-09
      • 1970-01-01
      • 2017-01-25
      • 2021-10-22
      • 1970-01-01
      • 2018-09-29
      • 1970-01-01
      • 2020-08-29
      • 1970-01-01
      相关资源
      最近更新 更多