Update gRPC queries
Proposal to update gRPC endpoint to be more flexible. Currently, the Retrieve Entities endpoint can support three different types of queries. We talked adding an additional composite query, however, thinking about it more I feel like just updating existing queries could provide the required flexibility and also closely mimic graphql queries.
-
entities_by_hashed_keys- no changes, input an array of hashed_keys and returns corresponding entities. Returns all entities if no hashed_keys supplied. -
entities_by_keys- currently requiresmodel_nameand an array of keys. The reason formodel_nameis for more efficient queries since it returns only entities of that type. The change here is to makemodel_nameoptional, so it can return all entities matching supplied keys. -
entities_by_member- returns entities matching a comparison operation on one member of a single model. Change this toentities_by_members(plural) and take multiple models and comparison operators on multiple members. This is effectively the composite query and pretty similar to what we have in gql.
@Larkooo @ponderingdemocritus @RareSecond let me know what you guys think and if there are q's
If we have entities_by_members why would we still need entities_by_keys? From a querying standpoint, we shouldn't really care about if a search field is a key or not.
Makes sense, I indeed think that the added composite query just adds complexity. One nice thing maybe is that with the composite query you could fetch entities_by_member + entities_by_hashed_keys. But I dont think it'll be very useful in a lot of cases
If we have
entities_by_memberswhy would we still needentities_by_keys? From a querying standpoint, we shouldn't really care about if a search field is akeyor not.
If you're querying for entire entities, the easiest way to filter on them is through the keys param since an entity is a collection of models that are associated by its keys. Looking at the interface propsal here, what we really also want is a models query, returning only specific models matching search fields and not entire entities.
I'm not sure if I'm entirely following @broody. Could you give concrete examples of the differences?
The first query requires just the keys array, while the second requires model name and member field params. Perhaps models_by_members is a better name for the second one.
But we can't work with the first one if we want full type safety, no? Because we need to know what models to expect back
On Thu, Mar 7, 2024, 18:19 Yun @.***> wrote:
The first query requires just the keys array, while the second requires model name and member field params. Perhaps models_by_members is a better name for the second one.
— Reply to this email directly, view it on GitHub https://github.com/dojoengine/dojo/issues/1613#issuecomment-1984043518, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2R5BW43CHF274QGGROE2DYXCOR5AVCNFSM6AAAAABEIDOV56VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBUGA2DGNJRHA . You are receiving this because you commented.Message ID: @.***>
Yes, for type safety use the second one, tho the side effect is you'll only receive entities consisting of specified models
Some previous work to keep in mind some changes that were planned: #1638.
Will close for now with the rework of composite queries. Will re-open more detailed issues based on the work to be achieved on gRPC and coming features.