laravel-restify icon indicating copy to clipboard operation
laravel-restify copied to clipboard

feat!: Adapt Restify to JSONAPI standards

Open maicol07 opened this issue 2 years ago • 7 comments

Fixes #558 Will fix: #562

Progress:

⚒️ means "Currently in progress"

maicol07 avatar Sep 04 '23 09:09 maicol07

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 $matchableAttributes was 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 $filters variable assignment received a minor modification in the filter() method using the dot() method.

  • Improvements in ValidatingTrait Class Updates were made to several methods involving a switch from using $k->attribute to $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 > attributes field. A few test methods have been updated accordingly to accommodate these changes. The affected classes include FieldActionTest, IndexRelatedFeatureTest, NestedRepositoryControllerTest, RepositoryIndexControllerTest, ProfileControllerTest, RepositoryShowControllerTest, ShowRelatedFeatureTest, and Prototypeable.

what-the-diff[bot] avatar Sep 04 '23 09:09 what-the-diff[bot]

I think you can use the $eagerState property instead of isRelationship.

binaryk avatar Sep 07 '23 07:09 binaryk

I think you can use the $eagerState property 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+?

maicol07 avatar Sep 07 '23 08:09 maicol07

@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:

https://github.com/maicol07/laravel-restify/blob/b0da4d86ab16b4ae9d05e118200d799e7213437b/src/Repositories/Repository.php#L542-L553

maicol07 avatar Oct 16 '23 14:10 maicol07

Thanks @maicol07 , can we make sure tests pass please?

binaryk avatar Dec 30 '23 08:12 binaryk

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?

maicol07 avatar Dec 30 '23 08:12 maicol07

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

netlify[bot] avatar Mar 13 '24 11:03 netlify[bot]

@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.

binaryk avatar Nov 30 '24 06:11 binaryk