Ash.Api.Dsl (ash v1.48.0-rc.12) View Source

A small DSL for declaring APIs

Apis are the entrypoints for working with your resources.

Apis may optionally include a list of resources, in which case they can be used as an Ash.Registry in various places. This is for backwards compatibility, but if at all possible you should define an Ash.Registry if you are using an extension that requires a list of resources. For example, most extensions look for two application environment variables called :ash_apis and :ash_registries to find any potential registries

Table of Contents

resources

List the resources present in this API

Examples:

resources do
  resource MyApp.User
  resource MyApp.Post
  resource MyApp.Comment
end

  • :define_interfaces? - If set to true, the code interface of each resource will be defined in the api.
    Keep in mind that this can increase the compile times of your application. The default value is false.

  • :registry - Allows declaring that only the modules in a certain registry should be allowed to work with this Api.
    This option is ignored if any explicit resources are included in the api, so everything is either in the registry or in the api. See the docs on Ash.Registry for what the registry is used for.

resource

A reference to a resource

Introspection Target:

Ash.Api.ResourceReference

Examples:

resource MyApp.User
  • :resource - Required. The module of the resource