-
-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw partial errors when failing to delete, forceDelete or restore a…
… model (#1420)
- Loading branch information
Showing
13 changed files
with
186 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Nuwave\Lighthouse\Execution; | ||
|
||
use GraphQL\Error\Error; | ||
use Throwable; | ||
|
||
class ErrorPool | ||
{ | ||
/** | ||
* The buffered errors. | ||
* | ||
* @var array<\Throwable> | ||
*/ | ||
protected $throwables = []; | ||
|
||
/** | ||
* Stores an error that will be added to the result. | ||
*/ | ||
public function record(Throwable $throwable): void | ||
{ | ||
$this->throwables [] = $throwable; | ||
} | ||
|
||
/** | ||
* @return array<\GraphQL\Error\Error> | ||
*/ | ||
public function errors(): array | ||
{ | ||
return array_map( | ||
function (Throwable $throwable): Error { | ||
if ($throwable instanceof Error) { | ||
return $throwable; | ||
} | ||
|
||
return new Error( | ||
$throwable->getMessage(), | ||
null, | ||
null, | ||
null, | ||
null, | ||
$throwable | ||
); | ||
}, | ||
$this->throwables | ||
); | ||
} | ||
|
||
public function clear(): void | ||
{ | ||
$this->throwables = []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.