Query handler breaking the dependency rule? #81
Replies: 4 comments
-
Good catch. |
Beta Was this translation helpful? Give feedback.
-
@Sairyss I'm concerned about a linter we use to block us from breaking the dependency rule. Also, regarding your alternative - how would you suggest to split it? |
Beta Was this translation helpful? Give feedback.
-
You can leave query handlers in application layer, but move slonik and SQL query strings into a separate adapter/repo class and inject it into query handlers (same principle as for example in create-user.service.ts ). or as you mentioned you can place queries in the infrastructure layer. Depends what you like more |
Beta Was this translation helpful? Give feedback.
-
Got it, thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi @Sairyss!
Thanks for this awesome repo! It's been super helpful. I did encounter an issue recently though -
According to the readme - queries should be part of the application layer. But when looking at find-users.query-handler.ts, we can see it's importing dependencies from an outer layer - the infrastructure layer (like
slonik
anduser.repository
).Doesn't that break the dependency rule? Or am I missing something?
If queries are at the same layer as application services, shouldn't they be required to use ports to communicate to "the outside world" just like application services are required to?
Thanks!
Simon
Beta Was this translation helpful? Give feedback.
All reactions