Skip to content

Commit

Permalink
docs: Remove the registry and use the resource format (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeofdan authored Oct 3, 2023
1 parent eab7619 commit 6671863
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions documentation/tutorials/getting-started-with-ash-and-phoenix.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,13 @@ config :my_ash_phoenix_app,
ash_apis: [MyAshPhoenixApp.Blog]
```

### Create the API and Registry
### Create the API and add Resources

An Ash API can be thought of as a [Bounded Context](https://martinfowler.com/bliki/BoundedContext.html) in Domain Driven Design terms and can seen as analogous to a Phoenix context. Put simply, its a way of grouping related resources together. In our case our API will be called `MyAshPhoenixApp.Blog`.

An Ash API points to an Ash registry. The registry in our case will be `MyAshPhoenixApp.Blog.Registry`
An Ash registry points to one or more resources. In our case we will only have a single resource `MyAshPhoenixApp.Blog.Post`. We'll be taking a deeper look into that in the next section.
An Ash API points to Ash resources. An Ash API can point to one or more resources. In our case we will only have a single resource `MyAshPhoenixApp.Blog.Post`. We'll be taking a deeper look into that in the next section.

For now take a look at the `Blog` API and the `Blog.Registry`:
For now take a look at the `Blog` API and the associated resources:

```elixir
# lib/my_ash_phoenix_app/blog/blog.ex
Expand All @@ -141,23 +140,7 @@ defmodule MyAshPhoenixApp.Blog do
use Ash.Api

resources do
registry MyAshPhoenixApp.Blog.Registry
end
end
```

```elixir
# lib/my_ash_phoenix_app/blog/registry.ex

defmodule MyAshPhoenixApp.Blog.Registry do
use Ash.Registry,
extensions: [
# This extension adds helpful compile time validations
Ash.Registry.ResourceValidations
]

entries do
entry MyAshPhoenixApp.Blog.Post
resource MyAshPhoenixApp.Blog.Post
end
end
```
Expand Down

0 comments on commit 6671863

Please sign in to comment.