php - 如何将 graphql 条件数组转换为 Eloquent Builder 类?
问题描述
我在我的 lighthouse-php 项目中使用构建器类进行 graphql 查询。以下是此方案的查询模式。
listings(
where: _ @builder(method: "App\\GraphQL\\Builders\\ListingsSearch") @whereConditions(columnsEnum: "ListingColumn"),
orderBy: _ @orderBy(columnsEnum: "ListingColumn") ): [Listing!]! @paginate(type:SIMPLE maxCount: 1500 defaultCount: 10)
我的ListingsSearch
构建器类有两个参数,第一个是查询构建器类,第二个是一个值,在这种情况下,它包含用户给出的 where 条件的数组。
例如对于以下查询;
{
"where": {
"AND": [{"column":"OWNERSHIP", "operator":"EQ", "value":["office","owned","fsbo","other"]}]
},
"orderBy": [],
"first": 25,
"page": 1
}
$value 参数内容为
array:2 [
"operator" => "="
"AND" => array:1 [
0 => array:3 [
"column" => "ownership"
"operator" => "="
"value" => array:4 [
0 => "office"
1 => "owned"
2 => "fsbo"
3 => "other"
]
]
]
]
我需要的是解释这个数组并将其转换为包含给定条件的查询构建器类。如果有人能带领我,我会很高兴。
解决方案
推荐阅读
- javascript - 如何在使用 Jest 测试 Node.js 应用程序时在调用的函数中模拟方法
- python - 关闭 R Notebook 中的警告
- python - Discord.py add_roles 问题
- javascript - 创建内部带有循环的异步函数
- xcode - NSPredicateEditorRowTemplate 从 keyPaths 恢复为常量值
- julia - 在 Julia 中获取嵌套数组的形状
- python - python中2D ifft的比例系数
- android - 如何使用锁屏密码代替指纹
- youtube - 您已经在 Adsense 上拥有一个现有帐户,但我没有
- javascript - 异步等待函数 .find() mongodb