首页 > 解决方案 > Graph QL 没有返回正确的数据

问题描述

我正在尝试运行图形 ql 查询以获取某些作业的详细信息。

查询是这样的:

query getJobsSearch(
$location: String
$type: String
$category: String
$time: String
$limit: Int
) {

jobs(order_by: {created_at: desc}, where: {deleted_at: {_is_null: true}, created_at: {_gt: "2021-06-16T10:06:38.551984+00:00"}, 
job_category: {slug: {_eq: $category}}, 
location: {slug: {_eq: $location}}, 
job_type: {slug: {_eq: $type}}}, limit: $limit)

现在,如果 $category、$location 或 $type 为空,它不会返回正确的结果。

它实际上给我返回了一个空数组。

如果我删除这个:

job_category: {slug: {_eq: $category}}, 
location: {slug: {_eq: $location}}, 
job_type: {slug: {_eq: $type}}}, limit: $limit)

它工作正常。

有人可以告诉我哪里出错了吗?

标签: reactjsgraphql

解决方案


推荐阅读