context#




Classes#

class RootskiDataLoaders#

class rootski.gql.context.RootskiDataLoaders(word_by_id__loader: strawberry.dataloader.DataLoader[str, rootski.schemas.word.Word])[source]#

Bases: object

class RootskiGraphQLContext#

class rootski.gql.context.RootskiGraphQLContext(user: rootski.schemas.user.User, request: starlette.requests.Request, session: sqlalchemy.ext.asyncio.session.AsyncSession, _RootskiGraphQLContext__loaders: Optional[rootski.gql.context.RootskiDataLoaders] = None)[source]#

Bases: object

property loaders: rootski.gql.context.RootskiDataLoaders#

Lazy create the RootskiDataLoaders.

Initializing the DataLoader instances in this way allows the DataLoader instances to be aware of the other RootskiGraphQLContext attributes such as the request, user, and session.

This approach was deemed appropriate because it allows the DataLoaders to be able to connect to the appropriate backend database or fetch data based on the logged in user WITHOUT needing to rely on global variables.