我需要用一些类似的谓词编写graphql查询
Select * from User Where loginId like "abc%"
在GraphQL:中
{
getWithPredicate(clazz : String, predicates : Predicates){
loginId
enabled
accountLocked
accountExpired
accountExpireBy
createdBy
}
}
如果graphql中有任何默认实现可用,请提出建议。
提前谢谢。
这是可能的。我曾经写过这样一个查询。我需要使用一些搜索词来搜索数据库。
query ($title: String!, $company: String!, $city: String!, $investor: String!) {
jobs(
where: {
and: [
{ title: { ilike: $title } },
{ company: { name: { ilike: $company } } },
{ city: { ilike: $city } },
{company: {company_investors:{investor:{name: {ilike: $investor}}}}}
]
}
) {
id
title
city
company {
name
id
company_investors {
investor {
name
id
}
}
}
}
}
# glob: I want all the titles that contain the word 'History'.
# The wildcard * stands for any non-empty string.
example_glob: allMarkdownRemark(
filter: { frontmatter: { title: { glob: "*History*" } } }
) {
edges {
node {
frontmatter {
title
}
}
}
}
可能的操作员的完整列表
eq:
是等于的缩写,必须与给定的数据完全匹配ne:
(的缩写(不等于,必须与给定的数据不同regex:
是正则表达式的缩写,必须与给定的模式匹配glob:
是全局的缩写,允许使用通配符*作为任何非空字符串的占位符in:
是数组中的缩写,必须是数组的元素nin:
是的缩写,不在数组中,必须不是数组的元素gt:
是大于的缩写,必须大于给定值gte:
是大于或等于的缩写,必须大于或等于至给定值lt:
是小于的缩写,必须小于给定值lte:
是小于或等于的缩写,必须小于或等于给定值elemMatch:
是元素匹配的缩写,这表示您are筛选将返回一个元素数组,您可以在该数组上使用以前的操作员应用过滤器