examples/02_blog/Schema/PostType.php 1 location
|
@@ 28-30 (lines=3) @@
|
| 25 |
|
'args' => [ |
| 26 |
|
'truncated' => new BooleanType() |
| 27 |
|
], |
| 28 |
|
'resolve' => function ($value, $args) { |
| 29 |
|
return (!empty($args['truncated'])) ? explode(' ', $value)[0] . '...' : $value; |
| 30 |
|
} |
| 31 |
|
]) |
| 32 |
|
->addField('title', new NonNullType(new StringType())) |
| 33 |
|
->addField('status', new PostStatus()) |
examples/02_blog_inline/inline-schema.php 1 location
|
@@ 27-30 (lines=4) @@
|
| 24 |
|
'args' => [ |
| 25 |
|
'truncated' => new BooleanType() // add an optional argument |
| 26 |
|
], |
| 27 |
|
'resolve' => function ($value, $args) { |
| 28 |
|
// used argument to modify a field value |
| 29 |
|
return (!empty($args['truncated'])) ? explode(' ', $value)[0] . '...' : $value; |
| 30 |
|
} |
| 31 |
|
], |
| 32 |
|
// if field just has a type, you can use a short declaration syntax like this |
| 33 |
|
'summary' => new StringType(), |