Open johannesschobel opened 5 years ago
To clarify the issue described above:
If i run ng serve api
, i get the following output:
WARNING in Circular dependency detected:
libs\api\auth\src\index.ts ->
libs\api\auth\src\lib\api-auth.ts ->
libs\api\auth\src\lib\auth.module.ts ->
libs\api\auth\src\lib\controllers\auth.controller.ts ->
libs\api\auth\src\lib\services\auth.service.ts ->
libs\api\auth\src\lib\data\entities\account.entity.ts ->
libs\api\profile\src\index.ts ->
libs\api\profile\src\lib\api-profile.ts ->
libs\api\profile\src\lib\profile.module.ts ->
libs\api\profile\src\lib\controllers\myself.controller.ts ->
libs\api\profile\src\lib\services\myself.service.ts ->
libs\api\profile\src\lib\services\profile.service.ts ->
libs\api\profile\src\lib\data\entities\profile.entity.ts ->
libs\api\auth\src\index.ts
formatted for better readability
Dear @beeman ,
again, i am sorry to bother you. I ran into an issue I would like to ask you about your opinion. In #2 , we already discussed about the overall project structure (how to build libs, apps should be "empty shells" and so on).
I then began to restructure my api (built with nest) and move everything into dedicated libs. So i created an
libs/api/auth
, anlibs/api/user
, ... library and link them together in alib/api/main
lib that may then be imported in theapps/api
project. So far so good.However, i quickly ran into "circular dependency" issues. Consider the following example: I have the 2 libs
api/auth
andapi/profile
both with their respective models. Thereby, oneAccount
has oneProfile
assigned (i.e., there is a@OneToOne(...)
relationship between them!) From the "data model" perspective, this is entirely valid and true, but boom - there you have your circular dependency!How do you deal with such issues? For me it makes sense to store the entities all in one place (i.e., in their respective library). However, this dramatically increases the connections / dependencies between the libraries, making it extremely hard to deal with circular dependencies.
What is your approach? All the best and cheers