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

Does not re-give relationships in query type a.b.c

Open PHPist opened this issue 2 years ago • 7 comments

Models relationships

Houses HasMany  Apartments	
Apartments BelongsTo Owner
Apartments BelongsTo House
Owner HasMany  Phones

GET /houses/1?include=apartments.owner.phones returns

https://jsoneditoronline.org/#left=cloud.15ee4ba500164dc9bce7386c5506263b&right=cloud.7126537776eb42c1bd1c35efdb49c4d8

Two apartments in the building (number 50, 88) belong to the same owner. The first object has owner.phones in the second one does not. Alt text

example: https://github.com/PHPist/restify-test

PHPist avatar Aug 04 '23 13:08 PHPist

This is relevant for me, can it be fixed?

RuslanYakovlev avatar Sep 27 '23 13:09 RuslanYakovlev

I have the same problem... I hope guys you fix this bug as soon as possible

ibaskakovidurak avatar Sep 27 '23 13:09 ibaskakovidurak

+1

npm-fork avatar Sep 27 '23 14:09 npm-fork

Hi @PHPist , thank you for the issue well documented.

Could you ensure please the json URL is correct?

image

binaryk avatar Sep 28 '23 14:09 binaryk

https://jsoneditoronline.org/#left=cloud.7126537776eb42c1bd1c35efdb49c4d8

PHPist avatar Sep 28 '23 15:09 PHPist

The problem is here.

This was a performance enhancement to not load the same data twice from the DB.

Still looking into a good fix:

CleanShot 2023-09-29 at 18 17 56@2x

binaryk avatar Sep 29 '23 15:09 binaryk

Thanks for the quick reply! Yes I saw that and assumed it was an optimization too. We even wanted to figure out how to flesh this out on the front end of the app. But the behavior is very unpredictable. So repeating the relationships would be the right thing to do. Like Laravel does (with, load).

PHPist avatar Sep 29 '23 15:09 PHPist