Table inheritance #610
Replies: 4 comments
-
Hi, welcome and thanks for opening @mihoward21 ! Will get back to you with a longer response shortly. In the meantime, can you share an example of a query that you run against your subgraph that uses an inherited/"interface" entity? |
Beta Was this translation helpful? Give feedback.
-
Here's our current subgraph: https://thegraph.com/hosted-service/subgraph/0xsplits/splits-subgraph-ethereum Here's two sample queries that highlight what I'm talking about:
The first just fetches accounts ordered by latest block they were updated. This is a simplified version of a query we run in our app to give users a live view of recent activity. As I mentioned, You can see our schema here if it helps: https://github.com/0xSplits/splits-subgraph/blob/master/schema.template.graphql |
Beta Was this translation helpful? Give feedback.
-
Thanks, that's helpful. BackgroundThis isn't a direct answer, but some background might help explain why this isn't an easy decision. In a subgraph, the Ponder's Database table inheritanceIn database design, I'd consider table inheritance a relatively niche feature.
Considering how young Ponder's database schema definition API is, I doubt we’ll support this any time soon. It’s also worth mentioning that the Graph does not use table inheritance to implement interfaces. GraphQL entity inheritanceWith all that said, I think inheritance (via interfaces) at the GraphQL layer is handy, and I can see that you are using it to great effect in your subgraph. I think there will be a clearer path forward here once we ship direct database access and fully decouple the GraphQL API from the database API. Will add that we're very excited to unblock y'all at 0xSplits, and posts like this genuinely help us prioritize. Thanks for your patience. |
Beta Was this translation helpful? Give feedback.
-
Thanks for all that background, that's super helpful. Definitely makes sense what you are saying, supporting it at the GraphQL layer. I think if we were starting from scratch we could certainly design without this. Have really enjoyed digging into Ponder. Not sure we're ready to switch over to it just yet, but have enjoyed playing around with it and am excited to (hopefully) use it in the future. |
Beta Was this translation helpful? Give feedback.
-
Can't find anything about this in the docs. Wonder if ponder supports table inheritance? Or there's some other way to accomplish that?
Basically right now in TheGraph I have an
Account
interface with just a few fields, then a bunch of entities that inherit that interface (each with their own unique fields). Is there any way to do something like that? The reason being I will need to do some queries onAccount
that will include all the different entities. There are also some relationships between the entities (i.e. theSplit
entity has acontroller
field that can be anyAccount
).Right now doing a separate table for each entity doesn't work (I think), because of that relationship issue (
controller
could be anyAccount
). But doing a singleAccount
table will get super messy because there will be a ton of optional fields for each different entity.Beta Was this translation helpful? Give feedback.
All reactions