graphprotocol / graph-node

Graph Node indexes data from blockchains such as Ethereum and serves it over GraphQL
https://thegraph.com
Apache License 2.0
2.91k stars 971 forks source link

Fetch entities from the store based on more than just the entity ID #3282

Open AlwaysBuyCheap opened 2 years ago

AlwaysBuyCheap commented 2 years ago

https://ethereum.stackexchange.com/questions/114310/the-graph-filter-query-by-relationship-non-id-value

I have these types:

type Poll @entity {
    id: ID!
    hash: String!
    contributions: [Contribution!]! @derivedFrom(field: "poll")
}

type Contribution @entity {
    id: ID!
    contributorAddress: Bytes!
    poll: Poll!
}

I need to query a poll filtered by the contribution contributorAddress but it seems that I'm only able to do it with the contribution ID.

Here are the mappings:

poll.contributions = new Array<string>(0)

let contributions = poll.contributions
contributions.push(contribution.id)
poll.contributions = contributions
azf20 commented 2 years ago

This is not currently possible - transferring to graph-node as that is where the change would be required. Thanks so much!