GraphQL\Examples\Blog\Types::mention PHP Method

mention() public static method

public static mention ( ) : SearchResultType
return GraphQL\Examples\Blog\Type\SearchResultType
    public static function mention()
    {
        return self::$mention ?: (self::$mention = new SearchResultType());
    }

Usage Example

Example #1
0
 public function __construct()
 {
     // Option #1: using composition over inheritance to define type, see ImageType for inheritance example
     $this->definition = new ObjectType(['name' => 'Story', 'fields' => function () {
         return ['id' => Types::id(), 'author' => Types::user(), 'mentions' => Types::listOf(Types::mention()), 'totalCommentCount' => Types::int(), 'comments' => ['type' => Types::listOf(Types::comment()), 'args' => ['after' => ['type' => Types::id(), 'description' => 'Load all comments listed after given comment ID'], 'limit' => ['type' => Types::int(), 'defaultValue' => 5]]], 'likes' => ['type' => Types::listOf(Types::user()), 'args' => ['limit' => ['type' => Types::int(), 'description' => 'Limit the number of recent likes returned', 'defaultValue' => 5]]], 'likedBy' => ['type' => Types::listOf(Types::user())], 'affordances' => Types::listOf(new EnumType(['name' => 'StoryAffordancesEnum', 'values' => [self::EDIT, self::DELETE, self::LIKE, self::UNLIKE, self::REPLY]])), 'hasViewerLiked' => Types::boolean(), Types::htmlField('body')];
     }, 'interfaces' => [Types::node()], 'resolveField' => function ($value, $args, $context, ResolveInfo $info) {
         if (method_exists($this, $info->fieldName)) {
             return $this->{$info->fieldName}($value, $args, $context, $info);
         } else {
             return $value->{$info->fieldName};
         }
     }]);
 }