# Logical OR using GraphQL

**URL:** <https://community.bitquery.io/t/logical-or-using-graphql/1147>\
**Category:** GraphQL API\
**Created:** [August 1, 2022, 12:18pm UTC](https://community.bitquery.io/t/logical-or-using-graphql/1147 "2022-08-01T12:18:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AFX](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@AFX](https://community.bitquery.io/u/AFX)\
**Post date:** [August 1, 2022, 12:18pm UTC](https://community.bitquery.io/t/logical-or-using-graphql/1147/1 "2022-08-01T12:18:47Z")

</div>

Hello everyone,

is there a way to use a logical OR when constructing a query? My use case is to find all transactions where the sender or the receiver is a specific address.

Thank you!

---

<div class="post-metadata">

**Author:** ![AFX](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@AFX](https://community.bitquery.io/u/AFX)\
**Post date:** [August 1, 2022, 1:27pm UTC](https://community.bitquery.io/t/logical-or-using-graphql/1147/2 "2022-08-01T13:27:00Z")

</div>

I have found a way:

```nohighlight
query ($network: EthereumNetwork!, $wallet: String!, $limit: Int!, $offset: Int!) {
  ethereum(network: $network) {
    transfers(
      options: {limit: $limit, offset: $offset}
      any: [ 
        {receiver: {is: $wallet}},
        {sender: {is: $wallet}}
      ]
      external: true
      success: true
    ) {
      amount
      currency {
        address
      }
      sender {
        address
      }
      receiver {
        address
      }
      transaction {
        hash
      }
    }
  }
}

```

If you have any advice how to make this request cheaper while returning the same result, I am all ears 🙂

---

<div class="post-metadata">

**Author:** ![AFX](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@AFX](https://community.bitquery.io/u/AFX)\
**Post date:** [August 1, 2022, 9:10pm UTC](https://community.bitquery.io/t/logical-or-using-graphql/1147/3 "2022-08-01T21:10:18Z")

</div>

Another follow up, the above request is cheaper when filtered by date (as answered by the Telegram community). It would be good to know if it can be improved further.

```auto
query ($network: EthereumNetwork!, $wallet: String!, $limit: Int!, $offset: Int!) {
  ethereum(network: $network) {
    transfers(
      options: {limit: $limit, offset: $offset}
      any: [{receiver: {is: $wallet}}, {sender: {is: $wallet}}]
      date: {after: "2022-01-01"}
    ) {
      amount
      currency {
        address
      }
      sender {
        address
      }
      receiver {
        address
      }
      external
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![bitquery-support](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@bitquery-support](https://community.bitquery.io/u/bitquery-support)\
**Post date:** [August 2, 2022, 1:26am UTC](https://community.bitquery.io/t/logical-or-using-graphql/1147/4 "2022-08-02T01:26:21Z")

</div>

This query is quite optimized, personally I don’t see any way to optimize it more, good job
