Skip to content

Commit

Permalink
Improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Jun 11, 2024
1 parent 8d5cbee commit 426eb56
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/Execution/ReportingErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ public function __invoke(?Error $error, \Closure $next): ?array
return $next(null);
}

// Client-safe errors are assumed to be something that a client can handle
// or is expected to happen, e.g. wrong syntax, authentication or validation
// Client-safe errors are assumed to be something that:
// - a client can understand and handle
// - were caused by client misuse, e.g. wrong syntax, authentication, validation
// Thus, they are typically not actionable for server developers.
if ($error->isClientSafe()) {
return $next($error);
}
Expand Down
7 changes: 3 additions & 4 deletions src/GraphQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ protected function errorsHandler(): callable
{
// @phpstan-ignore-next-line callable is not recognized correctly and can not be type-hinted to match
return $this->errorsHandler ??= function (array $errors, callable $formatter): array {
// User defined error handlers, implementing \Nuwave\Lighthouse\Execution\ErrorHandler
// User defined error handlers, implementing \Nuwave\Lighthouse\Execution\ErrorHandler.
// This allows the user to register multiple handlers and pipe the errors through.
$handlers = [];
foreach ($this->configRepository->get('lighthouse.error_handlers', []) as $handlerClass) {
Expand All @@ -331,11 +331,10 @@ protected function errorsHandler(): callable

protected function debugFlag(): int
{
// If debugging is set to false globally, do not add GraphQL specific
// debugging info either. If it is true, then we fetch the debug
// level from the Lighthouse configuration.
return $this->configRepository->get('app.debug')
// If Laravel debugging is enabled, we fetch the debug level from the Lighthouse configuration.
? (int) $this->configRepository->get('lighthouse.debug')
// If Laravel debugging is disabled, do not add GraphQL specific debugging info either.
: DebugFlag::NONE;
}

Expand Down
4 changes: 1 addition & 3 deletions src/Schema/Directives/ComplexityDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ public function complexityResolver(FieldValue $fieldValue): callable
/** @param array<string, mixed> $args */
public static function defaultComplexityResolver(int $childrenComplexity, array $args): int
{
/**
* Assuming pagination, @see PaginationManipulator::countArgument().
*/
/** Assuming pagination, @see PaginationManipulator::countArgument(). */
$first = $args['first'] ?? null;

$expectedNumberOfChildren = is_int($first)
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Contracts/CreatesResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
interface CreatesResponse
{
/**
* Create a HTTP response from the final result.
* Create an HTTP response from the final result.
*
* @param array<string, mixed>|array<int, array<string, mixed>> $result
*/
Expand Down

0 comments on commit 426eb56

Please sign in to comment.