Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No unified way of setting up SQLAlchemy sessions #223

Open
guilhermelou opened this issue Dec 5, 2024 · 0 comments
Open

No unified way of setting up SQLAlchemy sessions #223

guilhermelou opened this issue Dec 5, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@guilhermelou
Copy link

guilhermelou commented Dec 5, 2024

The session setup has to be done twice and ideally there should be a single point of contact for it.
As of now, there's a session setup for the Dataloader injected in the context and one for the relay connections, e.g.:

Session Setup For Dataloaders

# context is expected to have an instance of StrawberrySQLAlchemyLoader
class CustomGraphQLView(GraphQLView):
    def get_context(self):
        return {
            "sqlalchemy_loader": StrawberrySQLAlchemyLoader(bind=YOUR_SESSION),
        }

Session Setup For Relay

@mapper.type(fruit_table)
class Fruit(relay.Node):
    id: relay.NodeID[int]

@strawberry.type
class Query:
    fruits: relay.ListConnection[Fruit] = connection(sessionmaker=sessionmaker)

The issue had already been spotted by the author on this comment: #65 (comment) and discussed on a community-chat session.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@Ckk3 Ckk3 added the enhancement New feature or request label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants