Skip to content

elixir-dx/dx

Repository files navigation

Dx

Hex.pm Docs License Last Updated CI

Dx is an Elixir library that allows adding inferred properties to Ecto schemas, defined by rules based on fields, associations or other inferred properties. You can then load/query them as if they were Ecto fields or associations using Dx's API.

It allows you to write declarative and easy-to-read domain logic by defining WHAT the rules are without having to care about HOW to execute them.

Under the hood, Dx's evaluation engine loads associations as needed concurrently in batches and can even translate your logic to Ecto queries directly.

Installation

Add dx to your list of dependencies in mix.exs:

def deps do
  [
    {:dx, "~> 0.3.0"}
  ]
end

When running Dx within transactions, please also add the following, until absinthe-graphql/dataloader#129 is closed:

def deps do
  [
    {:dataloader, github: "arnodirlam/dataloader", branch: "async-option", override: true}
  ]
end

Configure your repo in config.exs:

config :dx, repo: MyApp.Repo

Import the formatter rules in .formatter.exs:

[
  import_deps: [:dx]
]

Guides

If you're new to Dx, the best place to start are the Guides.

Status

Dx was started at Team Engine, where we've been developing it internally since January 2021. We've been using it in production since March 2021, and increasingly port our business logic to it. To make it an easy-to-adopt open-source library, the next steps are to:

  • extract the code into this repo
  • re-add tests (because they were domain-specific)
  • write guides, a reference and an announcement
  • resolve absinthe-graphql/dataloader#129 and re-add dataloader as a hex dependency
  • find another name, because infer is already taken on hex.pm
  • release on hex.pm

Special thanks

This project is sponsored and kindly supported by Team Engine.

If you'd like to join us working on Dx and Refactory as a contractor, please reach out to @arnodirlam.

About

Inference engine written in Elixir

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages