Repo facade complexity

I currently have an umbrella with 3 apps.

  • Data.Repo - project-wide Repo
  • Context.Data - Repo facade with operations specific to Context. Contains schemas.
  • Context - Contextually specific business logic. Provides an interface that will eventually be used by a GraphQL app, REST app, etc.

My question is how complex should I allow the facade to get? Should I keep it basic and just provide CRUD-ish type operations? Do validations belong within the facade?

I’m curious to hear what others are doing.

1 Like

if the application only requires CRUD, and little dynamic querying then you can encapsulate most of Ecto behind your facade.

As soon as you need dynamic query building, or complex multi-step transactions I find it better to embrace Ecto Query/Changeset/Multi within your Context module. Leaving the facade to just defining the schemas.