| 1 | <?php |
||
| 12 | class ReadMembersQueryCreator extends QueryCreator implements OperationResolver |
||
| 13 | { |
||
| 14 | public function attributes() |
||
| 15 | { |
||
| 16 | return [ |
||
| 17 | 'name' => 'readMembers' |
||
| 18 | ]; |
||
| 19 | } |
||
| 20 | |||
| 21 | public function args() |
||
| 22 | { |
||
| 23 | return [ |
||
| 24 | 'ID' => ['type' => Type::string()], |
||
| 25 | 'Email' => ['type' => Type::string()], |
||
| 26 | 'Token' => ['type' => Type::string()] |
||
| 27 | ]; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function type() |
||
| 31 | { |
||
| 32 | return Type::listOf($this->manager->getType('member')); |
||
| 33 | } |
||
| 34 | |||
| 35 | public function resolve($object, array $args, $context, ResolveInfo $info) |
||
| 36 | { |
||
| 37 | $list = Member::get(); |
||
| 38 | |||
| 39 | // Optional filtering by properties |
||
| 40 | if (isset($args['Email'])) { |
||
| 41 | $list = $list->filter('Email', $args['Email']); |
||
| 42 | } |
||
| 43 | if (isset($args['ID'])) { |
||
| 44 | $list = $list->byID($args['ID']); |
||
| 45 | } |
||
| 46 | |||
| 47 | return $list; |
||
| 48 | } |
||
| 49 | } |
||
| 50 |