I have the following project structure:
|__workspaces
| |__db
| | |__create.py
| |__graphql
| | |__mutations.py
| | |__interfaces.py
In graphql.mutations
I have create mutation which create multiple workspaces:
class MutationWorkspacesCreate:
def __init__(self, workspaces_creator: WorkspacesCreatorI):
self._workspaces_creator = workspaces_creator
def __call__(self, ...) -> list[UUID]
...
await self._workspaces_creator.create(...)
This mutation depends on the class that implements the WorkspacesCreatorI interface:
class WorkspaceCreatorI(abc.ABC):
@abc.abstractmethod
async def create(self, schemas: WorkspaceCreateSchemaSet) -> list[UUID]
raise NotImplementedError
In db.create
I have class which implements this interface:
class DbWorkspacesCreator(WorkspacesCreatorI):
async def create(self, schemas: WorkspaceCreateSchemaSet) -> list[UUID]
...
But since I need to create several workspaces, I need to have some two dataclasses:
class WorkspaceCreateSchema(pydantic.BaseModel):
...
class WorkspaceCreateSchemaSet(pydantic.BaseModel):
items: list[WorkspaceCreateSchema]
If I put these dataclasses in the interfaces.py
file, it looks kind of weird, because they are not abstract classes, but fully implemented, plus they can be used in a module in the database from some other modules, so rather they belong to the database. But on the other hand, if I put them in the database, then it turns out strange that the graphql
package depends on the database
, and the database
on the graphql
.
Please advise where to put these dataclasses and why