Skip to content

Repositories ​

The repositories that run a field's query against the session, in sync and async variants.

StrawchemyAsyncRepository ​

source

python
StrawchemyAsyncRepository(type: type[T], info: Info[Any, Any], root_aggregations: bool = False, auto_snake_case: bool = True, query_hook: QueryHook[Any] | Sequence[QueryHook[Any]] | None = None, session_getter: AsyncSessionGetter = default_session_getter, session: AnyAsyncSession | None = None, filter_statement: SelectOf[Any] | None = None, execution_options: dict[str, Any] | None = None, deterministic_ordering: bool = False, default_order_by: builtins.list[OrderByExpr] = list()) -> None

Asynchronous strawberry implementation for GraphQL data access.

This class provides asynchronous methods for querying and mutating data through GraphQL, using SQLAlchemy's asynchronous API under the hood.

Parameters:

NameTypeDescriptionDefault
typetype[T]The Strawberry GraphQL type this strawberry works withrequired
infoInfo[Any, Any]The GraphQL resolver info objectrequired
session_getterAsyncSessionGetterCallable to get an async database sessiondefault_session_getter
sessionAnyAsyncSession | NoneOptional explicit async database session to useNone
filter_statementSelectOf[Any] | NoneOptional base SQLAlchemy select statement to apply to all queriesNone
execution_optionsdict[str, Any] | NoneOptional execution options for SQLAlchemyNone
deterministic_orderingboolWhether to ensure deterministic ordering of resultsFalse

auto_snake_case ​

python
auto_snake_case: bool = True

create ​

python
create(data: Input[InputModel]) -> GraphQLResult[InputModel, T]

Asynchronously create a new entity.

Parameters:

NameTypeDescriptionDefault
dataInput[InputModel]The input data for the new entityrequired

Returns:

TypeDescription
GraphQLResult[InputModel, T]A GraphQLResult containing the created entity

default_order_by ​

python
default_order_by: builtins.list[OrderByExpr] = field(default_factory=list)

delete ​

python
delete(filter_input: BooleanFilterDTO | None) -> GraphQLResult[Any, T]

Asynchronously delete entities matching the given filter.

Parameters:

NameTypeDescriptionDefault
filter_inputBooleanFilterDTO | NoneThe filter criteria to select entities to deleterequired

Returns:

TypeDescription
GraphQLResult[Any, T]A GraphQLResult containing the deleted entities

deterministic_ordering ​

python
deterministic_ordering: bool = False

execution_options ​

python
execution_options: dict[str, Any] | None = None

filter_statement ​

python
filter_statement: SelectOf[Any] | None = None

get_by_id ​

python
get_by_id(**kwargs: Any) -> GraphQLResult[Any, T]

Asynchronously get an entity by its primary key.

Parameters:

NameTypeDescriptionDefault
**kwargsAnyPrimary key field names and values{}

Returns:

TypeDescription
GraphQLResult[Any, T]A GraphQLResult containing the found entity

Raises:

TypeDescription
NoResultFoundIf no entity with the given ID exists

get_one ​

python
get_one(filter_input: BooleanFilterDTO | None = None, order_by: builtins.list[OrderByDTO] | None = None, distinct_on: builtins.list[EnumDTO] | None = None, limit: int | None = None, offset: int | None = None) -> GraphQLResult[Any, T]

Asynchronously get exactly one result matching the criteria.

Parameters:

NameTypeDescriptionDefault
filter_inputBooleanFilterDTO | NoneOptional filter conditionsNone
order_bylist[OrderByDTO] | NoneOptional ordering criteriaNone
distinct_onlist[EnumDTO] | NoneOptional fields to apply DISTINCT onNone
limitint | NoneOptional maximum number of results to returnNone
offsetint | NoneOptional number of results to skipNone

Returns:

TypeDescription
GraphQLResult[Any, T]A GraphQLResult containing the single result

Raises:

TypeDescription
NoResultFoundIf no results are found
MultipleResultsFoundIf multiple results are found

get_one_or_none ​

python
get_one_or_none(filter_input: BooleanFilterDTO | None = None, order_by: builtins.list[OrderByDTO] | None = None, distinct_on: builtins.list[EnumDTO] | None = None, limit: int | None = None, offset: int | None = None) -> GraphQLResult[Any, T]

Asynchronously get at most one result matching the criteria or None.

Parameters:

NameTypeDescriptionDefault
filter_inputBooleanFilterDTO | NoneOptional filter conditionsNone
order_bylist[OrderByDTO] | NoneOptional ordering criteriaNone
distinct_onlist[EnumDTO] | NoneOptional fields to apply DISTINCT onNone
limitint | NoneOptional maximum number of results to returnNone
offsetint | NoneOptional number of results to skipNone

Returns:

TypeDescription
GraphQLResult[Any, T]A GraphQLResult containing the result or None

graphql_repository ​

python
graphql_repository() -> SQLAlchemyGraphQLAsyncRepository[Any]

Create and configure the underlying async SQLAlchemy GraphQL strawberry.

Returns:

TypeDescription
SQLAlchemyGraphQLAsyncRepository[Any]A configured SQLAlchemyGraphQLAsyncRepository instance

info ​

python
info: Info[Any, Any]

is_async ​

python
is_async = IS_ASYNC_REPOSITORY

list ​

python
list(filter_input: BooleanFilterDTO | None = None, order_by: builtins.list[OrderByDTO] | None = None, distinct_on: builtins.list[EnumDTO] | None = None, limit: int | None = None, offset: int | None = None) -> GraphQLResult[Any, T]

Asynchronously get a list of entities matching the criteria.

Parameters:

NameTypeDescriptionDefault
filter_inputBooleanFilterDTO | NoneOptional filter conditionsNone
order_bylist[OrderByDTO] | NoneOptional ordering criteriaNone
distinct_onlist[EnumDTO] | NoneOptional fields to apply DISTINCT onNone
limitint | NoneOptional maximum number of results to returnNone
offsetint | NoneOptional number of results to skipNone

Returns:

TypeDescription
GraphQLResult[Any, T]A GraphQLResult containing the list of matching entities

query_hook ​

python
query_hook: QueryHook[Any] | Sequence[QueryHook[Any]] | None = None

root_aggregations ​

python
root_aggregations: bool = False

session ​

python
session: AnyAsyncSession | None = None

session_getter ​

python
session_getter: AsyncSessionGetter = default_session_getter

type ​

python
type: type[T]

update_by_filter ​

python
update_by_filter(data: Input[InputModel], filter_input: BooleanFilterDTO) -> GraphQLResult[InputModel, T]

Asynchronously update entities matching the given filter.

Parameters:

NameTypeDescriptionDefault
dataInput[InputModel]The input data containing fields to updaterequired
filter_inputBooleanFilterDTOThe filter criteria to select entities to updaterequired

Returns:

TypeDescription
GraphQLResult[InputModel, T]A GraphQLResult containing the updated entities

update_by_id ​

python
update_by_id(data: Input[InputModel]) -> GraphQLResult[InputModel, T]

Asynchronously update an entity by its ID.

Parameters:

NameTypeDescriptionDefault
dataInput[InputModel]The input data containing the ID and fields to updaterequired

Returns:

TypeDescription
GraphQLResult[InputModel, T]A GraphQLResult containing the updated entity

Raises:

TypeDescription
NoResultFoundIf no entity with the given ID exists

upsert ​

python
upsert(data: Input[InputModel], filter_input: BooleanFilterDTO | None = None, update_fields: builtins.list[EnumDTO] | None = None, conflict_fields: EnumDTO | None = None) -> GraphQLResult[InputModel, T]

Asynchronously insert or update an entity.

Parameters:

NameTypeDescriptionDefault
dataInput[InputModel]The input data for the entityrequired
filter_inputBooleanFilterDTO | NoneOptional filter to find existing entityNone
update_fieldslist[EnumDTO] | NoneOptional fields to update if entity existsNone
conflict_fieldsEnumDTO | NoneOptional fields to detect conflicts onNone

Returns:

TypeDescription
GraphQLResult[InputModel, T]A GraphQLResult containing the upserted entity

StrawchemySyncRepository ​

source

python
StrawchemySyncRepository(type: type[T], info: Info[Any, Any], root_aggregations: bool = False, auto_snake_case: bool = True, query_hook: QueryHook[Any] | Sequence[QueryHook[Any]] | None = None, session_getter: SyncSessionGetter = default_session_getter, session: AnySyncSession | None = None, filter_statement: SelectOf[Any] | None = None, execution_options: dict[str, Any] | None = None, deterministic_ordering: bool = False, default_order_by: builtins.list[OrderByExpr] = list()) -> None

Asynchronous strawberry implementation for GraphQL data access.

This class provides asynchronous methods for querying and mutating data through GraphQL, using SQLAlchemy's asynchronous API under the hood.

Parameters:

NameTypeDescriptionDefault
typetype[T]The Strawberry GraphQL type this strawberry works withrequired
infoInfo[Any, Any]The GraphQL resolver info objectrequired
session_getterSyncSessionGetterCallable to get an async database sessiondefault_session_getter
sessionAnySyncSession | NoneOptional explicit async database session to useNone
filter_statementSelectOf[Any] | NoneOptional base SQLAlchemy select statement to apply to all queriesNone
execution_optionsdict[str, Any] | NoneOptional execution options for SQLAlchemyNone
deterministic_orderingboolWhether to ensure deterministic ordering of resultsFalse

auto_snake_case ​

python
auto_snake_case: bool = True

create ​

python
create(data: Input[InputModel]) -> GraphQLResult[InputModel, T]

Asynchronously create a new entity.

Parameters:

NameTypeDescriptionDefault
dataInput[InputModel]The input data for the new entityrequired

Returns:

TypeDescription
GraphQLResult[InputModel, T]A GraphQLResult containing the created entity

default_order_by ​

python
default_order_by: builtins.list[OrderByExpr] = field(default_factory=list)

delete ​

python
delete(filter_input: BooleanFilterDTO | None) -> GraphQLResult[Any, T]

Asynchronously delete entities matching the given filter.

Parameters:

NameTypeDescriptionDefault
filter_inputBooleanFilterDTO | NoneThe filter criteria to select entities to deleterequired

Returns:

TypeDescription
GraphQLResult[Any, T]A GraphQLResult containing the deleted entities

deterministic_ordering ​

python
deterministic_ordering: bool = False

execution_options ​

python
execution_options: dict[str, Any] | None = None

filter_statement ​

python
filter_statement: SelectOf[Any] | None = None

get_by_id ​

python
get_by_id(**kwargs: Any) -> GraphQLResult[Any, T]

Asynchronously get an entity by its primary key.

Parameters:

NameTypeDescriptionDefault
**kwargsAnyPrimary key field names and values{}

Returns:

TypeDescription
GraphQLResult[Any, T]A GraphQLResult containing the found entity

Raises:

TypeDescription
NoResultFoundIf no entity with the given ID exists

get_one ​

python
get_one(filter_input: BooleanFilterDTO | None = None, order_by: builtins.list[OrderByDTO] | None = None, distinct_on: builtins.list[EnumDTO] | None = None, limit: int | None = None, offset: int | None = None) -> GraphQLResult[Any, T]

Asynchronously get exactly one result matching the criteria.

Parameters:

NameTypeDescriptionDefault
filter_inputBooleanFilterDTO | NoneOptional filter conditionsNone
order_bylist[OrderByDTO] | NoneOptional ordering criteriaNone
distinct_onlist[EnumDTO] | NoneOptional fields to apply DISTINCT onNone
limitint | NoneOptional maximum number of results to returnNone
offsetint | NoneOptional number of results to skipNone

Returns:

TypeDescription
GraphQLResult[Any, T]A GraphQLResult containing the single result

Raises:

TypeDescription
NoResultFoundIf no results are found
MultipleResultsFoundIf multiple results are found

get_one_or_none ​

python
get_one_or_none(filter_input: BooleanFilterDTO | None = None, order_by: builtins.list[OrderByDTO] | None = None, distinct_on: builtins.list[EnumDTO] | None = None, limit: int | None = None, offset: int | None = None) -> GraphQLResult[Any, T]

Asynchronously get at most one result matching the criteria or None.

Parameters:

NameTypeDescriptionDefault
filter_inputBooleanFilterDTO | NoneOptional filter conditionsNone
order_bylist[OrderByDTO] | NoneOptional ordering criteriaNone
distinct_onlist[EnumDTO] | NoneOptional fields to apply DISTINCT onNone
limitint | NoneOptional maximum number of results to returnNone
offsetint | NoneOptional number of results to skipNone

Returns:

TypeDescription
GraphQLResult[Any, T]A GraphQLResult containing the result or None

graphql_repository ​

python
graphql_repository() -> SQLAlchemyGraphQLSyncRepository[Any]

Create and configure the underlying async SQLAlchemy GraphQL strawberry.

Returns:

TypeDescription
SQLAlchemyGraphQLSyncRepository[Any]A configured SQLAlchemyGraphQLAsyncRepository instance

info ​

python
info: Info[Any, Any]

is_async ​

python
is_async = IS_SYNC_REPOSITORY

list ​

python
list(filter_input: BooleanFilterDTO | None = None, order_by: builtins.list[OrderByDTO] | None = None, distinct_on: builtins.list[EnumDTO] | None = None, limit: int | None = None, offset: int | None = None) -> GraphQLResult[Any, T]

Asynchronously get a list of entities matching the criteria.

Parameters:

NameTypeDescriptionDefault
filter_inputBooleanFilterDTO | NoneOptional filter conditionsNone
order_bylist[OrderByDTO] | NoneOptional ordering criteriaNone
distinct_onlist[EnumDTO] | NoneOptional fields to apply DISTINCT onNone
limitint | NoneOptional maximum number of results to returnNone
offsetint | NoneOptional number of results to skipNone

Returns:

TypeDescription
GraphQLResult[Any, T]A GraphQLResult containing the list of matching entities

query_hook ​

python
query_hook: QueryHook[Any] | Sequence[QueryHook[Any]] | None = None

root_aggregations ​

python
root_aggregations: bool = False

session ​

python
session: AnySyncSession | None = None

session_getter ​

python
session_getter: SyncSessionGetter = default_session_getter

type ​

python
type: type[T]

update_by_filter ​

python
update_by_filter(data: Input[InputModel], filter_input: BooleanFilterDTO) -> GraphQLResult[InputModel, T]

Asynchronously update entities matching the given filter.

Parameters:

NameTypeDescriptionDefault
dataInput[InputModel]The input data containing fields to updaterequired
filter_inputBooleanFilterDTOThe filter criteria to select entities to updaterequired

Returns:

TypeDescription
GraphQLResult[InputModel, T]A GraphQLResult containing the updated entities

update_by_id ​

python
update_by_id(data: Input[InputModel]) -> GraphQLResult[InputModel, T]

Asynchronously update an entity by its ID.

Parameters:

NameTypeDescriptionDefault
dataInput[InputModel]The input data containing the ID and fields to updaterequired

Returns:

TypeDescription
GraphQLResult[InputModel, T]A GraphQLResult containing the updated entity

Raises:

TypeDescription
NoResultFoundIf no entity with the given ID exists

upsert ​

python
upsert(data: Input[InputModel], filter_input: BooleanFilterDTO | None = None, update_fields: builtins.list[EnumDTO] | None = None, conflict_fields: EnumDTO | None = None) -> GraphQLResult[InputModel, T]

Asynchronously insert or update an entity.

Parameters:

NameTypeDescriptionDefault
dataInput[InputModel]The input data for the entityrequired
filter_inputBooleanFilterDTO | NoneOptional filter to find existing entityNone
update_fieldslist[EnumDTO] | NoneOptional fields to update if entity existsNone
conflict_fieldsEnumDTO | NoneOptional fields to detect conflicts onNone

Returns:

TypeDescription
GraphQLResult[InputModel, T]A GraphQLResult containing the upserted entity