I'm working on an API server (ASP.NET Core). To prevent spaghetti code and other nastiness in the future, I design the system following Clean Architecture/CQRS (using MediatR).
I'm considering to use GraphQL for the API instead of REST (Hot Chocolate GraphQL). In several examples from HotChocolate GraphQL, the database is directly queried using a GraphQL-EF mechanism. Though this might seem beneficial, I am worried this might complicate the code in the long run. The database structure might change, etc. The API should, in my opinion, remain separated from the repository layer. Even though more work, I believe GraphQL should communicate with CQRS instead.