From d2dc25cc07a60c9bfaa1cd33463fd87609f297da Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 25 Sep 2015 20:01:14 -0700 Subject: [PATCH] Improved syntax in starwars --- tests/starwars/schema.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/starwars/schema.py b/tests/starwars/schema.py index 018a1fc8..9fbee302 100644 --- a/tests/starwars/schema.py +++ b/tests/starwars/schema.py @@ -9,21 +9,24 @@ Episode = graphene.Enum('Episode', dict( JEDI = 6 )) + def wrap_character(character): if isinstance(character, _Human): return Human(character) elif isinstance(character, _Droid): return Droid(character) + class Character(graphene.Interface): id = graphene.IDField() name = graphene.StringField() - friends = graphene.ListField('Character') + friends = graphene.ListField('self') appearsIn = graphene.ListField(Episode) def resolve_friends(self, args, *_): return [wrap_character(getCharacter(f)) for f in self.instance.friends] + class Human(Character): homePlanet = graphene.StringField() @@ -50,8 +53,6 @@ class Query(graphene.ObjectType): @resolve_only_args def resolve_human(self, id): return wrap_character(getHuman(id)) - if human: - return Human(human) @resolve_only_args def resolve_droid(self, id):