flugg / laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal with Laravel's elegancy.
MIT License
862 stars 86 forks source link

Transformer mappings circular dependencies #106

Closed IlCallo closed 6 years ago

IlCallo commented 6 years ago

Now that it's possible to put mappings on $relations, I tried to add them everywhere. Then I got stuck into a cicular dependency of those mappings and a segmentation fault happened.

If I remember correctly, Fractal prevents circular dependencies cutting them down after X iterations, but with the new layer of mapping used to eager load relations I guess this behaviour wasn't taken into account.

flugg commented 6 years ago

Oh, this makes sense. We’re traversing the transformers recursively, and if two transformers reference each other I suppose it ends up with an endless loop. Can’t believe I didn’t think about this.

I’ll think some how we best can solve this, but it definitely needs fixing ASAP, as this sounds like a very normal use case

flugg commented 6 years ago

This is now fixed with v3.0.2