You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[GraphQL] Adding custom error format support (#3063)
* Adding GraphQL custom error format support
* Use error normalizers
* Changing error format to follow GraphQL spec
Co-authored-by: Alan Poulain <[email protected]>
throwError::createLocatedError(sprintf('Custom mutation resolver "%s" has to return an item of class %s but returned an item of class %s.', $mutationResolverId, $resourceMetadata->getShortName(), (new \ReflectionClass($itemClass))->getShortName()), $info->fieldNodes, $info->path);
108
+
thrownew \LogicException(sprintf('Custom mutation resolver "%s" has to return an item of class %s but returned an item of class %s.', $mutationResolverId, $resourceMetadata->getShortName(), (new \ReflectionClass($itemClass))->getShortName()));
$resourceClass = $this->getResourceClass($item, $resourceClass, $info, sprintf('Custom query resolver "%s"', $queryResolverId).' has to return an item of class %s but returned an item of class %s.');
82
+
$resourceClass = $this->getResourceClass($item, $resourceClass, sprintf('Custom query resolver "%s"', $queryResolverId).' has to return an item of class %s but returned an item of class %s.');
@@ -102,13 +101,13 @@ public function __invoke(?string $resourceClass = null, ?string $rootClass = nul
102
101
/**
103
102
* @param object|null $item
104
103
*
105
-
* @throws Error
104
+
* @throws \UnexpectedValueException
106
105
*/
107
-
privatefunctiongetResourceClass($item, ?string$resourceClass, ResolveInfo$info, string$errorMessage = 'Resolver only handles items of class %s but retrieved item is of class %s.'): string
106
+
privatefunctiongetResourceClass($item, ?string$resourceClass, string$errorMessage = 'Resolver only handles items of class %s but retrieved item is of class %s.'): string
108
107
{
109
108
if (null === $item) {
110
109
if (null === $resourceClass) {
111
-
throwError::createLocatedError('Resource class cannot be determined.', $info->fieldNodes, $info->path);
110
+
thrownew \UnexpectedValueException('Resource class cannot be determined.');
throwError::createLocatedError(sprintf($errorMessage, (new \ReflectionClass($resourceClass))->getShortName(), (new \ReflectionClass($itemClass))->getShortName()), $info->fieldNodes, $info->path);
123
+
thrownew \UnexpectedValueException(sprintf($errorMessage, (new \ReflectionClass($resourceClass))->getShortName(), (new \ReflectionClass($itemClass))->getShortName()));
0 commit comments