nuwave / lighthouse

A framework for serving GraphQL from Laravel
https://lighthouse-php.com
MIT License
3.33k stars 434 forks source link

Introduce ClientSafeModelNotFoundException for `@can` and `@canFind` directives #2522

Closed ChaplyginWezom closed 3 months ago

ChaplyginWezom commented 4 months ago

Resolves #2521

Changes

Added custom ClientSafeModelNotFoundException to wrap around ModelNotFoundException in @can and @canFind directives. New exception is linked to previous exception, allowing for usage in custom error handlers. With this change developers could be able to modify original exception how they want, formatting or replacing conditionally

Breaking changes

Probably none, as new exception being safely catched into same GraphQL\Error and maintain original message

ChaplyginWezom commented 3 months ago

Ok, so I've extended ModelNotFoundException and now mention of previous exception is redundant

spawnia commented 3 months ago

Thank you