Skip to content

Latest commit

 

History

History
40 lines (26 loc) · 1.18 KB

identities.md

File metadata and controls

40 lines (26 loc) · 1.18 KB

Identities

Identities can be used to describe the ways that a resource is uniquely identified. For example, you may have a user resource that has an id primary key, but is uniquely identifiable via the email attribute as well. To configure this, add an identities block to your resource

For example:

identities do
  identity :unique_email, [:email]
end

Effects

Identities are used in various ways across Ash and it's extensions. This list is not necessarily exhaustive:

Ash

  • Identities can be used with c:Ash.Api.get/3, e.g MyApi.get(User, [email: "foo@bar.com"])

AshPostgres

AshJsonApi

  • Get routes can be configured to use a specific identity, creating a route like GET /users/foo@bar.com

AshGraphql

  • Get queries and mutations can be configured to use a specific identity, to create a query like the following. (Arbitrary filtering is supported on list queries, this is is for creating queries that return a single result)
query{
  getUser(email: "foo@bar.com"){
      id
  }
}