mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 07:49:24 +03:00
Throwing GraphQL\Error\Error
vs GraphQL\Error\UserError
from type definitions
This commit is contained in:
parent
e6e531b88b
commit
08a68d4857
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Type\Definition;
|
namespace GraphQL\Type\Definition;
|
||||||
|
|
||||||
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Error\InvariantViolation;
|
use GraphQL\Error\InvariantViolation;
|
||||||
use GraphQL\Error\UserError;
|
|
||||||
use GraphQL\Language\AST\FloatValueNode;
|
use GraphQL\Language\AST\FloatValueNode;
|
||||||
use GraphQL\Language\AST\IntValueNode;
|
use GraphQL\Language\AST\IntValueNode;
|
||||||
use GraphQL\Utils\Utils;
|
use GraphQL\Utils\Utils;
|
||||||
@ -63,7 +63,7 @@ values as specified by
|
|||||||
$isInput ? Utils::printSafeJson($value) : Utils::printSafe($value)
|
$isInput ? Utils::printSafeJson($value) : Utils::printSafe($value)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
throw ($isInput ? new UserError($err) : new InvariantViolation($err));
|
throw ($isInput ? new Error($err) : new InvariantViolation($err));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Type\Definition;
|
namespace GraphQL\Type\Definition;
|
||||||
|
|
||||||
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Error\InvariantViolation;
|
use GraphQL\Error\InvariantViolation;
|
||||||
use GraphQL\Error\UserError;
|
|
||||||
use GraphQL\Language\AST\IntValueNode;
|
use GraphQL\Language\AST\IntValueNode;
|
||||||
use GraphQL\Language\AST\StringValueNode;
|
use GraphQL\Language\AST\StringValueNode;
|
||||||
use GraphQL\Utils\Utils;
|
use GraphQL\Utils\Utils;
|
||||||
@ -65,7 +65,7 @@ When expected as an input type, any string (such as `"4"`) or integer
|
|||||||
return 'null';
|
return 'null';
|
||||||
}
|
}
|
||||||
if (!is_scalar($value)) {
|
if (!is_scalar($value)) {
|
||||||
throw new UserError("ID type cannot represent non scalar value: " . Utils::printSafeJson($value));
|
throw new Error("ID type cannot represent non scalar value: " . Utils::printSafeJson($value));
|
||||||
}
|
}
|
||||||
return (string) $value;
|
return (string) $value;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Type\Definition;
|
namespace GraphQL\Type\Definition;
|
||||||
|
|
||||||
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Error\InvariantViolation;
|
use GraphQL\Error\InvariantViolation;
|
||||||
use GraphQL\Error\UserError;
|
|
||||||
use GraphQL\Language\AST\IntValueNode;
|
use GraphQL\Language\AST\IntValueNode;
|
||||||
use GraphQL\Utils\Utils;
|
use GraphQL\Utils\Utils;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ values. Int can represent values between -(2^31) and 2^31 - 1. ';
|
|||||||
*/
|
*/
|
||||||
private function coerceInt($value, $isInput)
|
private function coerceInt($value, $isInput)
|
||||||
{
|
{
|
||||||
$errClass = $isInput ? UserError::class : InvariantViolation::class;
|
$errClass = $isInput ? Error::class : InvariantViolation::class;
|
||||||
|
|
||||||
if ($value === '') {
|
if ($value === '') {
|
||||||
throw new $errClass(
|
throw new $errClass(
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Type\Definition;
|
namespace GraphQL\Type\Definition;
|
||||||
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Error\InvariantViolation;
|
use GraphQL\Error\InvariantViolation;
|
||||||
use GraphQL\Error\UserError;
|
|
||||||
use GraphQL\Utils\Utils;
|
use GraphQL\Utils\Utils;
|
||||||
|
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ class ObjectType extends Type implements OutputType, CompositeType
|
|||||||
$this->getFields();
|
$this->getFields();
|
||||||
}
|
}
|
||||||
if (!isset($this->fields[$name])) {
|
if (!isset($this->fields[$name])) {
|
||||||
throw new UserError(sprintf("Field '%s' is not defined for type '%s'", $name, $this->name));
|
throw new Error(sprintf("Field '%s' is not defined for type '%s'", $name, $this->name));
|
||||||
}
|
}
|
||||||
return $this->fields[$name];
|
return $this->fields[$name];
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Type\Definition;
|
namespace GraphQL\Type\Definition;
|
||||||
|
|
||||||
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Error\InvariantViolation;
|
use GraphQL\Error\InvariantViolation;
|
||||||
use GraphQL\Error\UserError;
|
|
||||||
use GraphQL\Language\AST\StringValueNode;
|
use GraphQL\Language\AST\StringValueNode;
|
||||||
use GraphQL\Utils\Utils;
|
use GraphQL\Utils\Utils;
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ represent free-form human-readable text.';
|
|||||||
return 'null';
|
return 'null';
|
||||||
}
|
}
|
||||||
if (!is_scalar($value)) {
|
if (!is_scalar($value)) {
|
||||||
throw new UserError("String cannot represent non scalar value: " . Utils::printSafe($value));
|
throw new Error("String cannot represent non scalar value: " . Utils::printSafe($value));
|
||||||
}
|
}
|
||||||
return (string) $value;
|
return (string) $value;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user