Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ability to filter on relationships #149

Open
maaft opened this issue Jan 2, 2025 · 0 comments
Open

ability to filter on relationships #149

maaft opened this issue Jan 2, 2025 · 0 comments

Comments

@maaft
Copy link
Contributor

maaft commented Jan 2, 2025

It would be very useful to filter on relationships.

For example I have two events:

  • GameCreated(uint32 gameId, address player1);
  • GameStarted(uint32 gameId, address playerWhite, address playerBlack);

I want to get all games that have "my" address. I have two options:

  1. Do two separate queries, filter player1 for GameCreated, filter playerWhite or playerBlack for GameStarted
  2. Define relationships and do one query while filtering on the relationship:
query GetGames($address: String!) {
  allGameCreateds(filter: {
    gameStartedsByGameId {
      playerWhite: {equalTo: $address}
    }
  }) {
    nodes {
      gameId
      player1
      gameStartedsByGameId {
        nodes {
          playerWhite
          playerBlack
        }
      }
    }
    totalCount
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant