ash-project / ash_json_api

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

Including `default_fields` for a specific route generates a compilation error #161

Closed sevenseacat closed 1 month ago

sevenseacat commented 1 month ago

Describe the bug According to https://hexdocs.pm/ash_json_api/dsl-ashjsonapi-resource.html#json_api-routes-index, we should be able to provide default_fields for individual routes, to be included in the response.

Trying to do this generates a compilation error, though:

index :search do
  default_fields [:cover_image_url, :latest_album_year_released, :album_count]
end

Generates:

error: function default_fields/1 imported from both AshJsonApi.Resource.JsonApi.Routes.Index.Options and 
AshJsonApi.Resource.JsonApi.Options, call is ambiguous
  lib/tunez/music/artist.ex:44:9

This is the only call to default_fields in the app - this is the first resource I'm setting up.

Expected behavior

The app should compile, and accessing the index route should return a JSON structure with those three fields in the response for each record.

** Runtime

zachdaniel commented 1 month ago

Fixed in the latest release of spark.