GraphQL\Examples\Blog\Type\StoryType::affordances PHP Method

affordances() public method

public affordances ( Story $story, $args, AppContext $context )
$story GraphQL\Examples\Blog\Data\Story
$context GraphQL\Examples\Blog\AppContext
    public function affordances(Story $story, $args, AppContext $context)
    {
        $isViewer = $context->viewer === DataSource::findUser($story->authorId);
        $isLiked = DataSource::isLikedBy($story->id, $context->viewer->id);
        if ($isViewer) {
            $affordances[] = self::EDIT;
            $affordances[] = self::DELETE;
        }
        if ($isLiked) {
            $affordances[] = self::UNLIKE;
        } else {
            $affordances[] = self::LIKE;
        }
        return $affordances;
    }