mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-25 06:16:05 +03:00
Several other updates to blog example
This commit is contained in:
parent
85d2c2cef3
commit
5125741899
@ -104,6 +104,11 @@ class DataSource
|
|||||||
return isset($this->stories[$id]) ? $this->stories[$id] : null;
|
return isset($this->stories[$id]) ? $this->stories[$id] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function findComment($id)
|
||||||
|
{
|
||||||
|
return isset($this->comments[$id]) ? $this->comments[$id] : null;
|
||||||
|
}
|
||||||
|
|
||||||
public function findLastStoryFor($authorId)
|
public function findLastStoryFor($authorId)
|
||||||
{
|
{
|
||||||
$storiesFound = array_filter($this->stories, function(Story $story) use ($authorId) {
|
$storiesFound = array_filter($this->stories, function(Story $story) use ($authorId) {
|
||||||
|
@ -43,9 +43,17 @@ class CommentType extends BaseType
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function author(Comment $comment, $args, AppContext $context)
|
||||||
|
{
|
||||||
|
return $context->dataSource->findUser($comment->authorId);
|
||||||
|
}
|
||||||
|
|
||||||
public function parent(Comment $comment, $args, AppContext $context)
|
public function parent(Comment $comment, $args, AppContext $context)
|
||||||
{
|
{
|
||||||
return $context->dataSource->findReplies($comment->id, $args['limit'], $args['after']);
|
if ($comment->parentId) {
|
||||||
|
return $context->dataSource->findComment($comment->parentId);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function replies(Comment $comment, $args, AppContext $context)
|
public function replies(Comment $comment, $args, AppContext $context)
|
||||||
|
Loading…
Reference in New Issue
Block a user