Closed bellini666 closed 10 months ago
Thanks for adding the RELEASE.md
file!
Here's a preview of the changelog:
Initial relay connection/node support using Strawberry's relay integration.
Merging #65 (d86b98f) into main (bf75e07) will increase coverage by
6.26%
. Report is 1 commits behind head on main. The diff coverage is89.69%
.
Comparing bellini666:relay_integration
(9ef9785) with main
(af6a48c)
✅ 1
untouched benchmarks
hey everyone, I still need some time to fully review this. Will get back when I have done some more testing
Hey @erikwrede , @mattalbr
I just got back from djangocon and I'll get back to this PR during the weekend now.
One thing I was wondering here is regarding the fact that you need to have a session to query sqlalchemy objects.
Because of that I had to add a sessionmaker
attribute to the fields, and I notice that the data loaders require one as well.
I was thinking about a way to avoid that and I have a proposal. Let me know what you think and I can implement that in this PR:
The idea is to use contextvars to provide a session that will be used during the execution of a query. Not only the relay fields I'm defining here can use it, but the dataloaders can also use it instead of requiring a bind
argument.
Something like:
current_session = contextvars.ContextVar("current-session")
class SessionProviderExtension(SchemaExtension):
def __init__(self, sessionmaker):
self.sessionmaker = sessionmaker
def on_execute(self):
token = current_session.set(self.sessionmaker())
try:
yield
finally:
current_session.reset(token)
Of course we can also make the current_session be started lazely (create it when first accessing it)
What do you think?
@mattalbr @erikwrede think I addressed all of the comments in this PR
Let me know if there's anything else missing to be able to merge this
lgtm from my side, pending agreement on this from you:
Thank you! @mattalbr let me know if you want any extra changes in this
TODO:
node()