Skip to content

Commit 0625bbe

Browse files
committed
Add variations field to PageImageType.
1 parent b3b14f9 commit 0625bbe

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Type/Object/PageImageType.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Youshido\GraphQL\Type\Object\AbstractObjectType;
66
use Youshido\GraphQL\Type\Scalar\StringType;
77
use Youshido\GraphQL\Type\Scalar\IntType;
8+
use Youshido\GraphQL\Type\ListType\ListType;
89
use ProcessWire\GraphQL\Type\InterfaceType\PageFileInterfaceType;
910

1011
class PageImageType extends AbstractObjectType {
@@ -21,7 +22,7 @@ public function getDescription()
2122

2223
public function build($config)
2324
{
24-
25+
2526
$config->applyInterface(new PageFileInterfaceType());
2627

2728
$config->addfield('width', [
@@ -39,11 +40,19 @@ public function build($config)
3940
return (integer) $value->height;
4041
}
4142
]);
43+
44+
$config->addField('variations', [
45+
'type' => new ListType(new PageImageType()),
46+
'description' => 'Returns all size variations of the image.',
47+
'resolve' => function ($value) {
48+
return $value->getVariations();
49+
}
50+
]);
4251
}
4352

4453
public function getInterfaces()
4554
{
4655
return [ new PageFileInterfaceType() ];
4756
}
4857

49-
}
58+
}

0 commit comments

Comments
 (0)