【问题标题】:Translation from blaze query to GraphQL query从 blaze 查询转换为 GraphQL 查询
【发布时间】:2017-03-15 13:13:40
【问题描述】:

我有一个数据使用者,它是 Jupyter Notebook。有什么方法可以将 blaze 编写的查询转换为 graphQL 查询?

例如在 blaze 中我们有:

accounts[accounts.balance < 0].name

在 GraphQL 中我们可能有这样的:

{
accounts(balance<0)
{
name
}
}

【问题讨论】:

    标签: jupyter-notebook graphql blaze


    【解决方案1】:

    GraphQL 不公开任何内置过滤功能。可以通过参数的形式手动实现。因此,根据您的需要,您可以定义查询字段,例如:

    type Query {
        accounts(balanceBelow: Int!): [Account!]
    }
    

    或:

    type Constraint {
        fieldName: String!
        operator: OperatorEnum!
        value: String!
    }
    type Query {
        accounts(where: Constraint): [Account!]
    }
    

    或介于两者之间。但是,如果自定义查询过滤和聚合之类的东西在您的域中很常见,您可能会发现 GraphQL 是一个繁琐的选择。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-16
      • 2021-11-03
      • 1970-01-01
      • 2013-09-17
      • 2021-08-21
      • 2020-02-04
      • 2021-06-25
      • 2019-07-29
      相关资源
      最近更新 更多