| @@ 19-31 (lines=13) @@ | ||
| 16 | ||
| 17 | class CharacterInterface extends AbstractInterfaceType |
|
| 18 | { |
|
| 19 | public function build($config) |
|
| 20 | { |
|
| 21 | $config |
|
| 22 | ->addField('id', new NonNullType(new IdType())) |
|
| 23 | ->addField('name', new NonNullType(new StringType())) |
|
| 24 | ->addField('friends', [ |
|
| 25 | 'type' => new ListType(new CharacterInterface()), |
|
| 26 | 'resolve' => function ($value) { |
|
| 27 | return $value['friends']; |
|
| 28 | } |
|
| 29 | ]) |
|
| 30 | ->addField('appearsIn', new ListType(new EpisodeEnum())); |
|
| 31 | } |
|
| 32 | ||
| 33 | public function getDescription() |
|
| 34 | { |
|
| @@ 21-34 (lines=14) @@ | ||
| 18 | class HumanType extends AbstractObjectType |
|
| 19 | { |
|
| 20 | ||
| 21 | public function build($config) |
|
| 22 | { |
|
| 23 | $config |
|
| 24 | ->addField('id', new NonNullType(new IdType())) |
|
| 25 | ->addField('name', new NonNullType(new StringType())) |
|
| 26 | ->addField('friends', [ |
|
| 27 | 'type' => new ListType(new CharacterInterface()), |
|
| 28 | 'resolve' => function ($droid) { |
|
| 29 | return StarWarsData::getFriends($droid); |
|
| 30 | }, |
|
| 31 | ]) |
|
| 32 | ->addField('appearsIn', new ListType(new EpisodeEnum())) |
|
| 33 | ->addField('homePlanet', TypeMap::TYPE_STRING); |
|
| 34 | } |
|
| 35 | ||
| 36 | public function getInterfaces() |
|
| 37 | { |
|