feat!: Adapt Restify to JSONAPI standards
Fixes #558 Will fix: #562
Progress:
- Show/Index
- [x] Relationships (missing links)
- [x] Included
- [ ] ~Sparse fieldsets (low priority) #523~ (will be handled in #536)
- [ ] ~JSONAPI object (low priority)~
- [x] Relationships endpoints (low priority)
- [ ] ~Policies?~ (Policies are already used in related endpoints)
- [x] Filtering/Matching (with filter query parameter)
- [x] Relationships update when updating attributes
- [x] Tests
- [ ] ⚒️ Documentation
⚒️ means "Currently in progress"
PR Summary
-
Enhancement of RelatedCollection Class A new feature was added to filter out only the matchable items using a new
onlyMatchable()method in RelatedCollection class. -
Introduction of Matchable Attributes to EagerField A new property named
$matchableAttributeswas introduced into the EagerField class, equipped with corresponding methods to enable interaction, checking and retrieving matchable items. -
Enhancement of Filter in MatchFilter Class The
filter()method in the MatchFilter class can now accommodate an additional parameter$no_eager. The logic inside the method has been adjusted accordingly to incorporate this change. -
Adjustment of Filter Method in MatchesCollection The
$filtersvariable assignment received a minor modification in thefilter()method using thedot()method. -
Improvements in ValidatingTrait Class Updates were made to several methods involving a switch from using
$k->attributeto$k->getAttribute()when establishing the array keys. -
Expansion in InteractWithSearch Trait The
collectMatches()method now also identifies related matchable fields from the RelatedCollection, broadening its capabilities. -
Test Files Modifications Several changes were made to the test files to align with the aforementioned updates in the payload structure and in the JSON structure returned by the API. Assertions were also modified to check different array components. In addition, the test request payload structure received modifications in order to integrate the new
data>attributesfield. A few test methods have been updated accordingly to accommodate these changes. The affected classes includeFieldActionTest,IndexRelatedFeatureTest,NestedRepositoryControllerTest,RepositoryIndexControllerTest,ProfileControllerTest,RepositoryShowControllerTest,ShowRelatedFeatureTest, andPrototypeable.
I think you can use the $eagerState property instead of isRelationship.
I think you can use the
$eagerStateproperty instead of isRelationship.
The issue here is that $eagerState is used for the included (old relationships array). I need something else to identify the new slim relationships array and the included one. Maybe I can use an enum since Restify targets PHP 8.1+?
@binaryk I think the PR is ready to be reviewed. The only thing left is a documentation update to cover the new API format (I guess this can be labeled as Restify 9.0?)
There is also a test failing but I don't know how to fix it (I think I need your help for this one :sweat_smile:)! Basically, it seems nested relationships aren't added to included. Related code:
Thanks @maicol07 , can we make sure tests pass please?
Thanks @maicol07 , can we make sure tests pass please?
Yes, I want the last test to pass, however I tried to debug it but I can't understand why nested relationships aren't loaded in included. Am I missing something?
Deploy Preview for laravel-restify-docs canceled.
| Name | Link |
|---|---|
| Latest commit | 3feefd12f37568f602c2f5445575d4071a50c4b0 |
| Latest deploy log | https://app.netlify.com/sites/laravel-restify-docs/deploys/65f191f1979b3800081247b1 |
@maicol07 I'll have to close this due to inactivity. Now we're on branch 9.x. Please let us know if you want to support it further.