You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See the condensed schema below for Uniswap and Exchange
# Uniswap global values across all exchangestypeUniswap@entity {
id: ID!exchanges: [Exchange!]!
.........
}
typeExchange@entity {
id: ID! # Uniswap Exchange address
...........
# Fields used to help derived relationshipfactory: Uniswap!@derivedFrom(field: "exchanges")
}
This is a bad pattern because we are deriving factory from exchange, while factory -> exchange has a relationship of 1-n . Right now we are deriving the factory from the exchanges, even though we know factory will always have id 1 and that there is only one factory. We should do the following:
# Uniswap global values across all exchangestypeUniswap@entity {
id: ID!exchanges: [Exchange!]!@derivedFrom(field: "factory")
......
}
typeExchange@entity {
id: ID! # Uniswap Exchange address
...........
factory: Uniswap!
}
And set each Exchanges factory value to the string 1. This will allow for simpler sql queries within graph-node
The text was updated successfully, but these errors were encountered:
davekaj
changed the title
Derived Uniswap.exchange rather than Exchange.factory
Derive Uniswap.exchange rather than Exchange.factory
Feb 27, 2020
Changing this is particularly pressing for Transaction and how events link to it as the current setup is causing a lot of very slow queries right now, and I haven't figured out a way to speed them up with additional indexes etc. If, for example, AddLiquidityEvent stored the Transaction it belongs to, and Transaction.addLiquidityEvents was derived, those queries would run a lot faster.
See the condensed schema below for
Uniswap
andExchange
This is a bad pattern because we are deriving factory from exchange, while factory -> exchange has a relationship of
1-n
. Right now we are deriving the factory from the exchanges, even though we know factory will always have id1
and that there is only one factory. We should do the following:And set each
Exchanges
factory value to the string1
. This will allow for simpler sql queries within graph-nodeThe text was updated successfully, but these errors were encountered: