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
Sqlalchemy in 1.4 support asynchronous I/O. I would like to know about plans to support async 1.4+ sqlalchemy. Will this be implemented in the graphene-sqlalchemy?
Reacted by ystreenn, Erik Wrede, maelnor and Jendrik Jördening
I would be willing to help on this with a PR, if the maintainers are interested 😉
I experimented a bit with it and what worked for me is to just overwrite the get_node method. An MVP is attached (sorry for it being a bit messy, but I copied it from my test project and therefore it is in multiple files 😉)
The question I would have about a possible PR is, if the asyncio part should be its own subpackage, similar to how sqlalchemy handles it (https://docs.sqlalchemy.org/en/14/orm/extensions/asyncio.html), or if another integration is preferable 😉 If the general structure is agreed, I would start with a draft PR 😉
The idea of implementing async sessions is great. @jendrikjoe How would your MVP work with batch loading or relationships in general?
I'll look into this next week and follow up with a more detailed reply!
From what I found relationships should be fine, if not loaded lazily, which would conflict with this section of the sqlalchemy docs: https://docs.sqlalchemy.org/en/14/orm/extensions/asyncio.html#preventing-implicit-io-when-using-asyncsession. So setting lazy in the relationships to "selectin" should keep everything working as is 😉
I can as well expand the tests to contain relationships and connections, but I would do that in a PR, so I am not cluttering this thrad 😆
We should clearly communicate the lack of support for certain lazy loading techniques then.
Additionally, I think a PR would require a more elegant solution than overriding the get_node classmethod for every type.
Maybe an option in the meta class (e.g. async= True/False) with a global default option would work?
This way we could implement the async functionality without using an extra subpackage - something I prefer since async mutations also implemented that way.
It seems like batching isn't working with sqa-1.4, so maybe that should be fixed first, since an async query should definitely be compatible with all the work done on the N+1 problem.
(#35 (comment))
Check batching.py, it seems to use a single session derived from query context.
I very much agree on all the point 👍 I will check if I can come up with something that moves this to the meta class 👍 I will check how the async mutations are done to figure, if I can draw inspiration from that. Same goes for the batching part 🙂
Hey, I've looked into it again.
If you want you can open a merge request with a proof of concept and we can start with that. This should change as little about things like batching as possible, while ensuring they still work. After that, things like adding the session maker (at the moment, graphene-SQA just uses a single session defined in the graphene-schema) should be taken care of. Looking forward to see what you come up with!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics referencing this issue.
Activity
jendrikjoe commentedon Apr 13, 2022
I would be willing to help on this with a PR, if the maintainers are interested 😉
I experimented a bit with it and what worked for me is to just overwrite the
get_nodemethod. An MVP is attached (sorry for it being a bit messy, but I copied it from my test project and therefore it is in multiple files 😉)The question I would have about a possible PR is, if the asyncio part should be its own subpackage, similar to how sqlalchemy handles it (https://docs.sqlalchemy.org/en/14/orm/extensions/asyncio.html), or if another integration is preferable 😉 If the general structure is agreed, I would start with a draft PR 😉
erikwrede commentedon Apr 13, 2022
The idea of implementing async sessions is great.
@jendrikjoe How would your MVP work with batch loading or relationships in general?
I'll look into this next week and follow up with a more detailed reply!
jendrikjoe commentedon Apr 14, 2022
From what I found relationships should be fine, if not loaded lazily, which would conflict with this section of the sqlalchemy docs: https://docs.sqlalchemy.org/en/14/orm/extensions/asyncio.html#preventing-implicit-io-when-using-asyncsession. So setting lazy in the relationships to
"selectin"should keep everything working as is 😉I can as well expand the tests to contain relationships and connections, but I would do that in a PR, so I am not cluttering this thrad 😆
erikwrede commentedon Apr 14, 2022
We should clearly communicate the lack of support for certain lazy loading techniques then.
Additionally, I think a PR would require a more elegant solution than overriding the get_node classmethod for every type.
Maybe an option in the meta class (e.g. async= True/False) with a global default option would work?
This way we could implement the async functionality without using an extra subpackage - something I prefer since async mutations also implemented that way.
It seems like batching isn't working with sqa-1.4, so maybe that should be fixed first, since an async query should definitely be compatible with all the work done on the N+1 problem.
(#35 (comment))
Check batching.py, it seems to use a single session derived from query context.
jendrikjoe commentedon Apr 14, 2022
I very much agree on all the point 👍 I will check if I can come up with something that moves this to the meta class 👍 I will check how the async mutations are done to figure, if I can draw inspiration from that. Same goes for the batching part 🙂
erikwrede commentedon Apr 27, 2022
Hey, I've looked into it again.
If you want you can open a merge request with a proof of concept and we can start with that. This should change as little about things like batching as possible, while ensuring they still work. After that, things like adding the session maker (at the moment, graphene-SQA just uses a single session defined in the graphene-schema) should be taken care of. Looking forward to see what you come up with!
Fred7b commentedon Apr 28, 2022
hey all. Thank You for response.
A few facts about what I did and what I use to solve problems in my project/
get_query() for async
form
to
and any updates in code lib.
I have plans to do mr. But I don't have enough time.
erikwrede commentedon Feb 15, 2023
Implemented in #350, thanks to @jendrikjoe☺️
github-actions commentedon Aug 15, 2023
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics referencing this issue.