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

comment() public static method

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

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' => 'Comment', 'fields' => function () {
         return ['id' => Types::id(), 'author' => Types::user(), 'parent' => Types::comment(), 'isAnonymous' => Types::boolean(), 'replies' => ['type' => Types::listOf(Types::comment()), 'args' => ['after' => Types::int(), 'limit' => ['type' => Types::int(), 'defaultValue' => 5]]], 'totalReplyCount' => Types::int(), Types::htmlField('body')];
     }, '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};
         }
     }]);
 }
All Usage Examples Of GraphQL\Examples\Blog\Types::comment