[GraphQL] Filter Data Based on Query Arguments with GraphQL

Posted answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[GraphQL] Filter Data Based on Query Arguments with GraphQL相关的知识,希望对你有一定的参考价值。

With GraphQL, every field and nested object can have a set of arguments which can be used to request very specific data from a GraphQL API. In this lesson, we will pass arguments to the GitHub API inline and as query variables.

 

We can named query:

query UserInfo {

}

 

We can pass in arguements into query:

query UserInfo ($login: String="xxx"){}

 

The same as function in javascript, we can give default params and use it in query:

query UserInfo ($login: String="xxx"){ 
  user(login:$login) {
    name,
    company,
    followers {
      totalCount
    }
  }
}

技术分享图片

以上是关于[GraphQL] Filter Data Based on Query Arguments with GraphQL的主要内容,如果未能解决你的问题,请参考以下文章

GraphQL:使用多个可选参数创建请求

如何在 Connect 组件下的 graphql 查询中使用 $filter 变量?

GatsbyJS 中的 GraphQL 过滤器

Spring shiro学习

使用 GraphQL +Ariadne + Flask 上传文件:graphql.error.graphql_error.GraphQLError: Operation data should be

TypeError: data.Order.map 不是函数( react 和 graphql )