Skip to content

Commit e6de05b

Browse files
authored
Update Post.php
1 parent d124daa commit e6de05b

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

Model/Resolver/Post.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,16 @@ public function resolve(
4444
array $value = null,
4545
array $args = null
4646
) {
47-
$fields = $info->getFieldSelection();
4847
$postId = $this->getPostId($args);
49-
return $this->getPostData($postId, $fields);
48+
$fields = $info ? $info->getFieldSelection(10) : null;
49+
50+
try {
51+
$postData = $this->postDataProvider->getData($postId, $fields);
52+
} catch (NoSuchEntityException $e) {
53+
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
54+
}
55+
56+
return $postData;
5057
}
5158

5259
/**
@@ -62,20 +69,4 @@ private function getPostId(array $args): string
6269

6370
return (string)$args['id'];
6471
}
65-
66-
/**
67-
* @param string $postId
68-
* @param array $fields
69-
* @return array
70-
* @throws GraphQlNoSuchEntityException
71-
*/
72-
private function getPostData(string $postId, array $fields): array
73-
{
74-
try {
75-
$postData = $this->postDataProvider->getData($postId, $fields);
76-
} catch (NoSuchEntityException $e) {
77-
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
78-
}
79-
return $postData;
80-
}
8172
}

0 commit comments

Comments
 (0)