ash-project / ash_json_api

The JSON:API extension for the Ash Framework
https://hexdocs.pm/ash_json_api
MIT License
56 stars 40 forks source link

Bug: Adding aggregate fields to json api query results in an error #110

Closed gordoneliel closed 8 months ago

gordoneliel commented 8 months ago

Issue

Adding an aggregate field to a json_api query causes a crash.

Example query

fields[json_api_resource_type]="foo,aggregate_bar"

Stacktrace below:

** (UndefinedFunctionError) function nil.embedded?/0 is undefined

 nil.embedded?()

 (ash_json_api 0.34.1) lib/ash_json_api/serializer.ex:698: anonymous fn/5 in AshJsonApi.Serializer.serialize_attributes/2

 (elixir 1.15.7) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3

(ash_json_api 0.34.1) lib/ash_json_api/serializer.ex:456: AshJsonApi.Serializer.serialize_one_record/2

(elixir 1.15.7) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2

 (ash_json_api 0.34.1) lib/ash_json_api/serializer.ex:39: AshJsonApi.Serializer.serialize_many/3

 (ash_json_api 0.34.1) lib/ash_json_api/controllers/response.ex:50: AshJsonApi.Controllers.Response.render_many/5

 (form_service 0.1.0) deps/plug/lib/plug/router.ex:246: anonymous fn/4 in FormServiceWeb.Forms.Router.dispatch/2

Runtime