Skip to content
New issue

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

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

Already on GitHub? # to your account

Complex filtering logic in tokens() query? #70

Open
rodrigoescandon opened this issue Jul 4, 2022 · 1 comment
Open

Complex filtering logic in tokens() query? #70

rodrigoescandon opened this issue Jul 4, 2022 · 1 comment

Comments

@rodrigoescandon
Copy link

If I run the following query, I get all tokens with that match the attribute filter {traitType: "Eyes", value: "classic"} or {traitType: "Hat", value: "strawberry hat"}. Is there a way to filter using complicated logic? For example, a way to get tokens that match both attributes (intersection of sets rather than union)? I tried using the standard and, or, and not operators from GraphQL but couldn't figure out how to pass them to the tokens query.

  query Query {
    tokens(
      filter: {attributeFilters: [
        {traitType: "Eyes", value: "classic"},
      	{traitType: "Hat", value: "strawberry hat"}
      ]},
      where: {collectionAddresses: "0x5af0d9827e0c53e4799bb226655a1de152a425a5"},
      pagination: {limit: 12},
      sort: {sortKey: MINTED, sortDirection: ASC}
    ) {
      nodes {
        token {
          tokenId
          attributes {
            traitType
            value
          }
        }
      }
    }
  }
@iainnash
Copy link
Collaborator

iainnash commented Aug 9, 2022

@rodrigoescandon I believe we can add this but it'll require some custom query logic on our end. I believe one issue with more complex nested logic is the query load could get quite high without collection filter (say all tokens owned by someone that owns 11k tokens with a nested and or and not filter etc). Can see how this will be useful and will bring it up to the team.

@sjiang2019

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants