Two major things have changed in AshJsonApi
1.0.
The error handling has been revamped to be more in line with patterns around Ash and AshGraphql. To implement custom errors, or to enable additional Ash errors to be displayed by AshJsonApi, you will implement the AshJsonApi.ToJsonApiError
protocol. Here is how its done for one of the builtin errors:
defimpl AshJsonApi.ToJsonApiError, for: Ash.Error.Changes.InvalidChanges do
def to_json_api_error(error) do
%AshJsonApi.Error{
id: Ash.UUID.generate(),
status_code: AshJsonApi.Error.class_to_status(error.class),
code: "invalid",
title: "Invalid",
source_parameter: to_string(error.field),
detail: error.message,
meta: Map.new(error.vars)
}
end
end
Previously, AshJsonApi called Ash.Changeset.manage_relationship
on the changeset built for the action. Now, you have to define the argument and manage_relationship yourself. See the relationships guide for more.
Your Router module file (the module that has use AshJsonApi.Router
in it) will need all references to api
updated to be domain
. eg.
defmodule MyApp.MyApi.Router do
use AshJsonApi.Router,
domains: [MyApp.Domain1, MyApp.Domain2],
...