laravel - GraphQL - Laravel - 默认为 OrderBy
问题描述
我正在为 laravel 运行灯塔,但默认情况下它不起作用@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
解决方案
您必须确保至少在Lighthouse v5.1.0上运行。
推荐阅读
- javascript - 单击在 Javascript 中不起作用时更改 HTML 按钮样式
- gradle - 使用 Gradle 将 Java 类从 Swagger 定义生成到独立 JAR
- mongodb - 使用猫鼬获取嵌套文档
- c# - WebClient、httpWebRequest 和外部 zabbix .exe 无法连接到网盘
- java - Google Bigquery 加载具有本地文件大小限制的数据
- python - 从 xml 文件中检索数据到 mysql 数据库
- c++ - 如何静态链接 Qt 库?
- ios - 如何在 Swift 中为我的标签添加大纲?
- android - 使用 Android Native 代码作为 Android Titanium 模块
- sql - SQL查询选择结果依赖于两个值