Skip to content

Commit

Permalink
Updated dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Václav Pelíšek committed Nov 10, 2023
1 parent 44ef3a1 commit 5b4c631
Show file tree
Hide file tree
Showing 80 changed files with 195 additions and 399 deletions.
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
"require": {
"php": ">=8.1",
"ext-json": "*",
"infinityloop-dev/graphpinator-parser": "^1.1",
"infinityloop-dev/graphpinator-common": "^1.2",
"infinityloop-dev/utils": "^2.2",
"nette/utils": "^3.2",
"psr/http-message": "^1.1 || ^2.0",
"infinityloop-dev/graphpinator-parser": "^1.2",
"infinityloop-dev/graphpinator-common": "^2.0",
"infinityloop-dev/utils": "^2.3",
"psr/http-message": "^2.0",
"psr/log": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
"infection/infection": "^0.26 || ^0.27",
"phpunit/phpunit": "^10.4",
"infection/infection": "^0.27",
"phpstan/phpstan": "^1.10",
"infinityloop-dev/coding-standard": "^0.2"
},
Expand Down
255 changes: 81 additions & 174 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/Exception/Value/InvalidValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ final class InvalidValue extends \Graphpinator\Exception\Value\ValueError

public function __construct(string $type, mixed $rawValue, bool $outputable)
{
$this->messageArgs = [$type, $this->printValue($rawValue)];

parent::__construct($outputable);
parent::__construct($outputable, [$type, $this->printValue($rawValue)]);
}

private function printValue(mixed $rawValue) : string
Expand Down
3 changes: 2 additions & 1 deletion src/Exception/Value/ValueError.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ abstract class ValueError extends \Graphpinator\Exception\GraphpinatorBase
{
public function __construct(
protected bool $outputable,
array $messageArgs = [],
)
{
parent::__construct();
parent::__construct($messageArgs);
}

public function isOutputable() : bool
Expand Down
40 changes: 35 additions & 5 deletions src/Graphpinator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

final class Graphpinator implements \Psr\Log\LoggerAwareInterface
{
use \Nette\SmartObject;

/**
* Whether Graphpinator should perform schema integrity checks. Disable in production to avoid unnecessary overhead.
*/
Expand Down Expand Up @@ -93,9 +91,9 @@ public function run(\Graphpinator\Request\RequestFactory $requestFactory) : \Gra
$this->logger->log(self::getLogLevel($exception), self::getLogMessage($exception));

return new \Graphpinator\Result(null, [
$exception instanceof \Graphpinator\Exception\GraphpinatorBase
? $exception
: \Graphpinator\Exception\GraphpinatorBase::notOutputableResponse(),
$exception instanceof \Graphpinator\Exception\ClientAware
? self::serializeError($exception)
: self::notOutputableResponse(),
]);
}
}
Expand All @@ -120,4 +118,36 @@ private static function getLogLevel(\Throwable $exception) : string

return \Psr\Log\LogLevel::EMERGENCY;
}

private static function serializeError(\Graphpinator\Exception\ClientAware $exception) : array
{
if (!$exception->isOutputable()) {
return self::notOutputableResponse();
}

$result = [
'message' => $exception->getMessage(),
];

if ($exception->getLocation() instanceof \Graphpinator\Common\Location) {
$result['locations'] = [$exception->getLocation()];
}

if ($exception->getPath() instanceof \Graphpinator\Common\Path) {
$result['path'] = $exception->getPath();
}

if (\is_array($exception->getExtensions())) {
$result['extensions'] = $exception->getExtensions();
}

return $result;
}

private static function notOutputableResponse() : array
{
return [
'message' => 'Server responded with unknown error.',
];
}
}
2 changes: 0 additions & 2 deletions src/Introspection/TypeKindVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

final class TypeKindVisitor implements \Graphpinator\Typesystem\Contract\TypeVisitor
{
use \Nette\SmartObject;

public function visitType(\Graphpinator\Typesystem\Type $type) : string
{
return TypeKind::OBJECT;
Expand Down
2 changes: 0 additions & 2 deletions src/Normalizer/Directive/Directive.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

final class Directive
{
use \Nette\SmartObject;

public function __construct(
private \Graphpinator\Typesystem\Contract\ExecutableDirective $directive,
private \Graphpinator\Value\ArgumentValueSet $arguments,
Expand Down
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/DirectiveIncorrectLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class DirectiveIncorrectLocation extends \Graphpinator\Normalizer\Exceptio

public function __construct(string $name)
{
$this->messageArgs = [$name];

parent::__construct();
parent::__construct([$name]);
}
}
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/DirectiveIncorrectUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class DirectiveIncorrectUsage extends \Graphpinator\Normalizer\Exception\N

public function __construct(string $name)
{
$this->messageArgs = [$name];

parent::__construct();
parent::__construct([$name]);
}
}
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/DirectiveNotExecutable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class DirectiveNotExecutable extends \Graphpinator\Normalizer\Exception\No

public function __construct(string $name)
{
$this->messageArgs = [$name];

parent::__construct();
parent::__construct([$name]);
}
}
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/DuplicatedDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class DuplicatedDirective extends \Graphpinator\Normalizer\Exception\Norma

public function __construct(string $name)
{
$this->messageArgs = [$name];

parent::__construct();
parent::__construct([$name]);
}
}
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/InvalidFragmentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class InvalidFragmentType extends \Graphpinator\Normalizer\Exception\Norma

public function __construct(string $childType, string $parentType)
{
$this->messageArgs = [$childType, $parentType];

parent::__construct();
parent::__construct([$childType, $parentType]);
}
}
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/OperationNotSupported.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class OperationNotSupported extends \Graphpinator\Normalizer\Exception\Nor

public function __construct(string $operation)
{
$this->messageArgs = [$operation];

parent::__construct();
parent::__construct([$operation]);
}
}
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/UnknownArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class UnknownArgument extends \Graphpinator\Normalizer\Exception\Normalize

public function __construct(string $argument)
{
$this->messageArgs = [$argument];

parent::__construct();
parent::__construct([$argument]);
}
}
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/UnknownDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class UnknownDirective extends \Graphpinator\Normalizer\Exception\Normaliz

public function __construct(string $name)
{
$this->messageArgs = [$name];

parent::__construct();
parent::__construct([$name]);
}
}
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/UnknownField.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class UnknownField extends \Graphpinator\Normalizer\Exception\NormalizerEr

public function __construct(string $field, string $type)
{
$this->messageArgs = [$field, $type];

parent::__construct();
parent::__construct([$field, $type]);
}
}
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/UnknownFragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class UnknownFragment extends \Graphpinator\Normalizer\Exception\Normalize

public function __construct(string $fragmentName)
{
$this->messageArgs = [$fragmentName];

parent::__construct();
parent::__construct([$fragmentName]);
}
}
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/UnknownType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class UnknownType extends \Graphpinator\Normalizer\Exception\NormalizerErr

public function __construct(string $type)
{
$this->messageArgs = [$type];

parent::__construct();
parent::__construct([$type]);
}
}
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/UnknownVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class UnknownVariable extends \Graphpinator\Normalizer\Exception\Normalize

public function __construct(string $varName)
{
$this->messageArgs = [$varName];

parent::__construct();
parent::__construct([$varName]);
}
}
4 changes: 1 addition & 3 deletions src/Normalizer/Exception/VariableTypeInputable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ final class VariableTypeInputable extends \Graphpinator\Normalizer\Exception\Nor

public function __construct(string $name)
{
$this->messageArgs = [$name];

parent::__construct();
parent::__construct([$name]);
}
}
2 changes: 0 additions & 2 deletions src/Normalizer/FinalizedRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

final class FinalizedRequest
{
use \Nette\SmartObject;

public function __construct(
private \Graphpinator\Normalizer\Operation\Operation $operation,
)
Expand Down
2 changes: 0 additions & 2 deletions src/Normalizer/Finalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

final class Finalizer
{
use \Nette\SmartObject;

private \Graphpinator\Common\Path $path;

public function finalize(NormalizedRequest $normalizedRequest, \stdClass $variables, ?string $operationName) : FinalizedRequest
Expand Down
2 changes: 0 additions & 2 deletions src/Normalizer/FragmentCycleValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

final class FragmentCycleValidator
{
use \Nette\SmartObject;

private array $stack = [];
private array $validated = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Normalizer/GetFieldVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function visitUnion(\Graphpinator\Typesystem\UnionType $union) : Field

public function visitInput(\Graphpinator\Typesystem\InputType $input) : mixed
{
throw new \Nette\InvalidStateException();
throw new \LogicException();
}

public function visitScalar(\Graphpinator\Typesystem\ScalarType $scalar) : Field
Expand Down
2 changes: 0 additions & 2 deletions src/Normalizer/NormalizedRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

final class NormalizedRequest
{
use \Nette\SmartObject;

public function __construct(
private \Graphpinator\Normalizer\Operation\OperationSet $operations,
)
Expand Down
16 changes: 7 additions & 9 deletions src/Normalizer/Normalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

namespace Graphpinator\Normalizer;

use \Graphpinator\Typesystem\Location\ExecutableDirectiveLocation;
use \Graphpinator\Normalizer\Directive\DirectiveSet;
use \Graphpinator\Normalizer\Variable\Variable;
use \Graphpinator\Normalizer\Variable\VariableSet;
use \Graphpinator\Normalizer\Directive\DirectiveSet;
use \Graphpinator\Typesystem\Location\ExecutableDirectiveLocation;

final class Normalizer
{
use \Nette\SmartObject;

private \Graphpinator\Common\Path $path;
private \SplStack $scopeStack;
private \Graphpinator\Parser\Fragment\FragmentSet $fragmentDefinitions;
Expand Down Expand Up @@ -62,9 +60,9 @@ private function normalizeOperation(
) : \Graphpinator\Normalizer\Operation\Operation
{
$rootObject = match ($operation->getType()) {
\Graphpinator\Tokenizer\OperationType::QUERY => $this->schema->getQuery(),
\Graphpinator\Tokenizer\OperationType::MUTATION => $this->schema->getMutation(),
\Graphpinator\Tokenizer\OperationType::SUBSCRIPTION => $this->schema->getSubscription(),
\Graphpinator\Tokenizer\TokenType::QUERY->value => $this->schema->getQuery(),
\Graphpinator\Tokenizer\TokenType::MUTATION->value => $this->schema->getMutation(),
\Graphpinator\Tokenizer\TokenType::SUBSCRIPTION->value => $this->schema->getSubscription(),
};

if (!$rootObject instanceof \Graphpinator\Typesystem\Type) {
Expand Down Expand Up @@ -321,7 +319,7 @@ private function normalizeFragmentSpread(
\Graphpinator\Parser\FragmentSpread\InlineFragmentSpread::class =>
$this->normalizeInlineFragmentSpread($fragmentSpread),
default =>
throw new \Nette\InvalidStateException(),
throw new \LogicException(),
};
}

Expand Down Expand Up @@ -389,7 +387,7 @@ private function normalizeTypeRef(
\Graphpinator\Parser\TypeRef\NotNullRef::class =>
new \Graphpinator\Typesystem\NotNullType($this->normalizeTypeRef($typeRef->getInnerRef())),
default =>
throw new \Nette\InvalidStateException(),
throw new \LogicException(),
};
}

Expand Down
2 changes: 0 additions & 2 deletions src/Normalizer/Operation/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

final class Operation
{
use \Nette\SmartObject;

public function __construct(
private string $type,
private ?string $name,
Expand Down
2 changes: 0 additions & 2 deletions src/Normalizer/RefinerModule/DuplicateFieldModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

final class DuplicateFieldModule implements RefinerModule, \Graphpinator\Normalizer\Selection\SelectionVisitor
{
use \Nette\SmartObject;

private array $fieldForName;
private int $index;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

final class DuplicateFragmentSpreadModule implements RefinerModule, \Graphpinator\Normalizer\Selection\SelectionVisitor
{
use \Nette\SmartObject;

private array $visitedFragments;
private int $index;

Expand Down
2 changes: 0 additions & 2 deletions src/Normalizer/RefinerModule/EmptyFragmentModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

final class EmptyFragmentModule implements RefinerModule, \Graphpinator\Normalizer\Selection\SelectionVisitor
{
use \Nette\SmartObject;

private int $index;

public function __construct(
Expand Down
2 changes: 0 additions & 2 deletions src/Normalizer/Selection/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

final class Field implements Selection
{
use \Nette\SmartObject;

public function __construct(
private \Graphpinator\Typesystem\Field\Field $field,
private string $outputName,
Expand Down
Loading

0 comments on commit 5b4c631

Please sign in to comment.