-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed 500 error when requesting include that didn't exist #1138
Conversation
cclep
commented
Aug 2, 2016
- Error was caused by the eager loading functionality
- Fix was to check for available includes if possible before blindly using them as an eager load
- This fix will quietly ignore invalid includes. We should consider throwing a http exception as a better fix
- Error was caused by the eager loading functionality - Fix was to check for available includes if possible before blindly using them as an eager load
Pulling master
Bump. @hskrasek can this get reviewed please? Thanks mate |
Is there an issue or something that this references? Not sure I fully understand the issue thats being fixed here |
a 500 error was thrown if an include not present in the 'available includes' is requested. This fixes this error by checking first if the include is valid. |
@cclep Do you have an example of that 500 error? |
@hskrasek when requesting ?include=doesntexist |
src/Transformer/Adapter/Fractal.php
Outdated
@@ -12,6 +12,7 @@ | |||
use League\Fractal\Resource\Collection as FractalCollection; | |||
use Illuminate\Database\Eloquent\Collection as EloquentCollection; | |||
use Illuminate\Contracts\Pagination\Paginator as IlluminatePaginator; | |||
use League\Fractal\TransformerAbstract; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import are ordered by length
One solution is to disable eager loading in Dingo and just handle it yourself. Not sure how viable that is though. Probably depends on your codebase |
@georaldc that removes half of the benefit of using dingo instead of fractal directly... |
Got the same problem when using model bindings. |
Solved the problem by registering a custom exception:
Not sure if this is really related to the actual pull request but may help someone. |
Just ran into this issue, the fix provided over 2 years ago resolves the issue for me. |
PR Merged. |