Added auth
This commit is contained in:
14
api/schema/extensions.py
Normal file
14
api/schema/extensions.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from strawberry.extensions import Extension
|
||||
|
||||
from api.database import SessionLocal
|
||||
|
||||
|
||||
class SQLAlchemySession(Extension):
|
||||
def on_request_start(self):
|
||||
self.execution_context.context["db"] = SessionLocal()
|
||||
|
||||
def on_request_end(self):
|
||||
self.execution_context.context["db"].close()
|
||||
|
||||
|
||||
extensions = (SQLAlchemySession,)
|
||||
Reference in New Issue
Block a user