dojo icon indicating copy to clipboard operation
dojo copied to clipboard

Torii graphql to use JOIN instead of subqueries to return custom types data

Open broody opened this issue 2 years ago • 10 comments

When querying for models with custom types there are inefficiencies due to how queries are executed. This ticket tracks this todo item here: https://github.com/dojoengine/dojo/blob/c2687e8fd18a51bf5ed1e67997dd7db0853c5643/crates/torii/graphql/src/object/model_data.rs#L175

Parent query: https://github.com/gianalarcon/dojo/blob/8de715d8691d987629948002fb8ba96d36b9990e/crates/torii/graphql/src/query/data.rs#L37

broody avatar Oct 03 '23 16:10 broody

Hello, I'll be interested about working on this one :)

azurwastaken avatar Oct 04 '23 14:10 azurwastaken

Sure! It's somewhat non-trivial as we build the graphql schema dynamically at runtime but feel free to reach out with any questions.

Here's the parent query: https://github.com/dojoengine/dojo/blob/b03bfb8d565d4d81b5afb98784d07741ca4d4f85/crates/torii/graphql/src/object/model_data.rs#L249

broody avatar Oct 04 '23 17:10 broody

@azurwastaken are you still planning to work on this?

tarrencev avatar Oct 12 '23 13:10 tarrencev

I can take this, we chatted offline and @azurwastaken will help with implementing some of the graphql testing

broody avatar Oct 12 '23 15:10 broody

Hi team. Any updates for this issue. Otherwise I would like to give it a try

gianalarcon avatar Oct 25 '23 03:10 gianalarcon

Ah I haven't gotten to it yet, all yours!

broody avatar Oct 25 '23 21:10 broody

Sure! It's somewhat non-trivial as we build the graphql schema dynamically at runtime but feel free to reach out with any questions.

Here's the parent query:

https://github.com/dojoengine/dojo/blob/b03bfb8d565d4d81b5afb98784d07741ca4d4f85/crates/torii/graphql/src/object/model_data.rs#L249

It seems like there is no parent query anymore. Now we have fn fetch_multiple_rows() instead https://github.com/gianalarcon/dojo/blob/8de715d8691d987629948002fb8ba96d36b9990e/crates/torii/graphql/src/query/data.rs#L37

@broody Can you confirm it and update the issue? Thanks

gianalarcon avatar Oct 26 '23 05:10 gianalarcon

It seems like there is no parent query anymore. Now we have fn fetch_multiple_rows() instead https://github.com/gianalarcon/dojo/blob/8de715d8691d987629948002fb8ba96d36b9990e/crates/torii/graphql/src/query/data.rs#L37

@broody Can you confirm it and update the issue? Thanks

Yeah, it's been generalized so could be used by all objects.

The challenge for model_data objects with nested types is after JOIN we get this flat sqlite row, connection_output will need to convert it properly to its value mapping with all the nested data.

broody avatar Oct 27 '23 00:10 broody

@broody is this still active?

ponderingdemocritus avatar Nov 30 '23 07:11 ponderingdemocritus

@broody is this still active?

Yes, we're gonna consolidate the queries from grpc and graphql which will resolve this issue.

broody avatar Dec 01 '23 02:12 broody

Will close to have consolidation follow up in #1395.

glihm avatar Jun 19 '24 22:06 glihm