如何进行不区分大小写的graphql查询?

时间:2018-12-21 02:45:56

标签: graphql

使用GraphQL来获取和解析配置文件,有时文件名是podfile,有时是Podfile,所以我想知道如何进行不区分大小写的查询吗?

现在我只能查询存储库->对象:podfile和Podfile,但是如果文件名是podFILE,则再次无效。

query($org_name: String!, $resp_name: String!)
                {
                repository(owner: $org_name name: $resp_name){
                          object: object(expression: "%s:proj.ios_mac/podfile"){
                                                              ... on Blob{
                                                                          text
                                                                          }
                                                              }
                          ios_object_1: object(expression: "%s:proj.ios_mac/Podfile"){
                                                              ... on Blob{
                                                                          text
                                                                          }
                                                              }
                          }
                }

REF:https://github.community/t5/How-to-use-Git-and-GitHub/graphql-api-resource-query-is-case-sensitive/m-p/6003

3 个答案:

答案 0 :(得分:2)

使用_ilike运算符使查询不区分大小写。

query MyQuery {
  heroes(where: {name: {_ilike: "%baTmaN%"}}) {name, movie }
}

来源和文档:https://github.com/hasura/graphql-engine/issues/1516

答案 1 :(得分:0)

根据spec,GraphQL中的名称区分大小写。名称包括字段名称,类型名称,变量名称等。

因此,简而言之,这是不可能的。

答案 2 :(得分:0)

_similar: "%key%" performs Case sensitive query
_ilike:   "%key%" performs case insensitive query

例如:下面的查询将返回名称包含iphone的所有设备。如果名称包含“ iPhone”(即查询区分大小写),它将无法返回对象。

query MyQuery {
  devices: devices(where: {name: { _similar: "%iphone%"}}) {
    name
 }
}

以下查询将返回名称包含“ iphone”,“ IPhone”的所有对象。即不区分大小写

query MyQuery {
  devices: devices(where: {name: { _ilike: "%iphone%"}}) {
    name
 }
}