Replies: 3 comments
-
You could very well keep this limited to infrastructure layer. The infra layer would have the library installed, interface defined and an (Service) extension method or a regular method which handles the DI. So, logicall, the following line would reside in Infra layer and you could call it from API startup.cs class. |
Beta Was this translation helpful? Give feedback.
-
@hirensharma |
Beta Was this translation helpful? Give feedback.
-
I consider calling an API similar to making a database call. You would have an interface in your core. Then have code in your core that your WebUI calls, which then calls methods on that interface. Then in your infrastructure, you would have a class that implements that interface. Your refit interface would reside in your infrastructure as well. The class that implements the interface from the core, would inject the refit interface through DI and call the refit methods to satisfy the methods from the interface from the core. For example if you have an interface in your core called IDataService, then you would implement that in your infrastructure and inject it into a class that your UI calls a method on in your core. In the infrastructure, you would have an interface for your refit API, let's call this IDataApi. Also in the infra, you have a class that implements the IDataService and injects IDataApi. Your core only knows about the IDataService. It also doesn't know or care how the data is retrieved. It can be an API call, a DB call, or getting the data from a file. |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
I want to start using Refit, but I'm facing a challenge to decouple the layers and respect the separation of concerns that CA solves.
Based on either of these templates for clean architecture:
Refit tights the abstraction and Implementation together where it forces the installation of the library in different layers which violates various principles and concerns.
Normally, these HttpClients Interfaces go into the core project(domain or application) where the implementation goes into the infrastructure project, but Refit does both.
So where should we place the Refit Interfaces to keep the core clean without reference to the external libraries based on any of the clean architecture templates?
Beta Was this translation helpful? Give feedback.
All reactions