-
How to request only the required fields from DB in resolvers. Let's say there's a request of a basic user info:
And the DB structure for user entity is much more complex, wide and "data-heavy". Now one would obviously trying to avoid getting all of the user info from a DB just to filter it on a server side and pass to a client only ids and names requested. I was wondering what solutions are considered to be optimal in this case (or is it even possible to make a universal solution not bound to a specific data structure, as there might be some additional data loads and joining involved). Yes, it could be done manually by getting requested fields from the resolver's info argument. Btw I'm also currently not bound to a specific DB or a data-provider like SQLAlchemy, as I'm trying to wrap my head around the abstract use-case. I would really appreciate your thoughts and experience on this one. Either abstract or with actual providers and databases. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You have two options here:
I vaguely remember a library existing in past for Graphene and Django that would build querysets based on query contents, but I also remember it was found very fast to be slow to work with. |
Beta Was this translation helpful? Give feedback.
-
This problem is also discussed in #1116 |
Beta Was this translation helpful? Give feedback.
You have two options here:
info
argroot_value
callable (this is what Ariadne GraphQL Proxy does)I vaguely remember a library existing in past for Graphene and Django that would build querysets based on query contents, but I also remember it was found very fast to be slow to work with.