when requiring the backing action to be named :get to be able to generate the self link, it is not imediately clear why the self link does not appear in the JSON:API response. Only after some digging and understanding that I would need to implement a specific action on all my resources for them to be able to link to themselfs, I found this piece of Code.
I would like to suggest, to better utilize the default :read action many resources have, or any other action the end user would like to use to back their JSON:API get route.
The route selection filter for the self link should then only require the HTTP method to be :get which is in scope of this project and not enforce restrictions on the backing action name, which in my opinion should be out of scope of this project and up to the end user of the framework.
I'm open to feedback if this is a good or terrible idea.
As a disclaimer, I'm just getting started with ash and ash_json_api so this might not be the way.
To see the test in action, I had to include some tags:
mix test --trace --include skip --include json_api_spec_1_0 --include spec_may test/spec_compliance/fetching_data/fetching_resources_test.exs
As a by product I've repaired some of the other test cases in that file to run again... I'm not too happy these changes are mixed, but could not think of a better place to include my own test case.
when requiring the backing action to be named
:get
to be able to generate the self link, it is not imediately clear why the self link does not appear in the JSON:API response. Only after some digging and understanding that I would need to implement a specific action on all my resources for them to be able to link to themselfs, I found this piece of Code.I would like to suggest, to better utilize the default
:read
action many resources have, or any other action the end user would like to use to back their JSON:APIget
route. The route selection filter for the self link should then only require the HTTP method to be:get
which is in scope of this project and not enforce restrictions on the backing action name, which in my opinion should be out of scope of this project and up to the end user of the framework.I'm open to feedback if this is a good or terrible idea. As a disclaimer, I'm just getting started with ash and ash_json_api so this might not be the way.
Testing
I've added a test to compliance test, as described in 5.2.7 Resource Links.
To see the test in action, I had to include some tags:
mix test --trace --include skip --include json_api_spec_1_0 --include spec_may test/spec_compliance/fetching_data/fetching_resources_test.exs
As a by product I've repaired some of the other test cases in that file to run again... I'm not too happy these changes are mixed, but could not think of a better place to include my own test case.
Contributor checklist