improvement: allow adding non-public attributes to explicit accept lists

docs: update upgrade guide
This commit is contained in:
Zach Daniel 2024-03-30 11:42:52 -04:00
parent 8175de4304
commit f885a0753f
2 changed files with 4 additions and 15 deletions

View file

@ -379,6 +379,10 @@ There is no longer a `private?` option for attributes, relationships, calculatio
If you are using api extensions (i.e `AshGraphql` and `AshJsonApi`), you will need to go to your resources and "invert" the definitions. i.e _remove_ `private?: true` and _add_ `public?: true` to _every other_ attribute, _relationship_ and _calculation_. Don't forget the relationships and calculations! If you are using api extensions (i.e `AshGraphql` and `AshJsonApi`), you will need to go to your resources and "invert" the definitions. i.e _remove_ `private?: true` and _add_ `public?: true` to _every other_ attribute, _relationship_ and _calculation_. Don't forget the relationships and calculations!
> ### Embedded resources too! {:.WARNING}
>
> The above includes embedded resources as well! Don't forget to make sure that all fields on your embedded resources are also marked as `public?: true` (if applicable). The goal here is to have a clear visual indicator of what in your application can be shown publically.
--- ---
### Anonymous calculations now operate on a list, just like module calculations ### Anonymous calculations now operate on a list, just like module calculations

View file

@ -71,21 +71,6 @@ defmodule Ash.Resource.Transformers.DefaultAccept do
""" """
end end
accept
|> Enum.reject(&(&1 in public_attribute_names))
|> case do
[] ->
:ok
invalid_attrs ->
raise Spark.Error.DslError,
module: Spark.Dsl.Transformer.get_persisted(dsl_state, :module),
path: [:actions, action.name, :accept],
message: """
Cannot accept #{inspect(invalid_attrs)}, because they are not public attributes.
"""
end
accept = accept =
Enum.reject(accept, &(&1 in argument_names)) Enum.reject(accept, &(&1 in argument_names))