【问题标题】:GraphQL query where clause usageGraphQL 查询 where 子句的使用
【发布时间】:2022-09-27 21:57:59
【问题描述】:

我不确定版本是否重要,但目前我使用的是 graphql 版本 15.8.0

这就是我想要做的。 我正在尝试同时通过account = \"string1\"transaction.from = \"string2\" 过滤查询。 我将在下面提供有关实体类型的详细信息。

type Swap @entity {
  id: ID!

  account: String!
  transaction: Transaction!
  timestamp: Int!
}

type Transaction @entity {
  id: ID!
  blockNumber: Int!
  timestamp: Int!
  from: String!
  to: String!
}

到目前为止,这是我尝试过的,它奏效了。 但我不知道如何过滤嵌套对象类型Transaction

`{
    swaps (
            first:1000
            orderBy: timestamp
            orderDirection: desc
            where: { account: \"0x9a64e084a6773180d9aca7eee0173d64ec8111f0\" }
        ) {

            transaction{
                id
                to
                from
            }
            timestamp
        }
    }`

我试过这个但没有用

`{
    swaps (
            first:1000
            orderBy: timestamp
            orderDirection: desc
            where: { account: \"0xaddress\" }
        ) {

            transactions (where: {from : \"0xaddress\"}) {
                id
                to
                from
            }
            timestamp
        }
    }`

    标签: node.js graphql graphql-js typegraphql thegraph


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 2020-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-14
      • 2021-11-16
      相关资源
      最近更新 更多