I want to get some info about some Uniswap transactions using The Graph but I don't know how to go about filtering.
I want to get only Swaps that one of their tokens is ether. That means that the symbol of the token is "ETH". Is there a way to do it?
The relevant GraphQL schema is:
type Swap @entity {
id: ID!
token0: Token!
token1: Token!
}
type Token @entity {
id: ID!
symbol: String!
}
Here is the complete GraphQL schema: https://thegraph.com/hosted-service/subgraph/uniswap/uniswap-v3?query=Example%20query
To make my question clearer, if this was SQL, I would query something like this:
SELECT Swap.id
FROM Swap JOIN Token ON Swap.token1_id == Token.id
WHERE Token.symbol
Thank you!
Filtering by subfield is a new feature just added to the Graph.
The syntax supported is as follows:
where: {token0_: { subfield : "value" }}For instance to get swaps where the first token has the symbol "WETH":
Result:
A more reliable way to do it would be to filter by token's ID, that way scam token someone named "WETH" would not be included, but I used symbol for the sake of clarity of the example.