diff --git a/examples/starwars/data.py b/examples/starwars/data.py index 856c9e50..ab8e957c 100644 --- a/examples/starwars/data.py +++ b/examples/starwars/data.py @@ -1,10 +1,10 @@ -humanData = {} -droidData = {} +human_data = {} +droid_data = {} def setup(): from .schema import Human, Droid - global humanData, droidData + global human_data, droid_data luke = Human( id='1000', name='Luke Skywalker', @@ -45,7 +45,7 @@ def setup(): home_planet=None, ) - humanData = { + human_data = { '1000': luke, '1001': vader, '1002': han, @@ -69,29 +69,29 @@ def setup(): primary_function='Astromech', ) - droidData = { + droid_data = { '2000': threepio, '2001': artoo, } -def getCharacter(id): - return humanData.get(id) or droidData.get(id) +def get_character(id): + return human_data.get(id) or droid_data.get(id) -def getFriends(character): - return map(getCharacter, character.friends) +def get_friends(character): + return map(get_character, character.friends) -def getHero(episode): +def get_hero(episode): if episode == 5: - return humanData['1000'] - return droidData['2001'] + return human_data['1000'] + return droid_data['2001'] -def getHuman(id): - return humanData.get(id) +def get_human(id): + return human_data.get(id) -def getDroid(id): - return droidData.get(id) +def get_droid(id): + return droid_data.get(id) diff --git a/examples/starwars/schema.py b/examples/starwars/schema.py index e6f113a8..9e4e2a2f 100644 --- a/examples/starwars/schema.py +++ b/examples/starwars/schema.py @@ -2,7 +2,7 @@ import graphene from graphene import resolve_only_args from graphql.core.type import GraphQLEnumValue -from .data import getCharacter, getDroid, getHero, getHuman +from .data import get_character, get_droid, get_hero, get_human Episode = graphene.Enum('Episode', dict( NEWHOPE=GraphQLEnumValue(4), @@ -19,7 +19,7 @@ class Character(graphene.Interface): def resolve_friends(self, args, *_): # The character friends is a list of strings - return [getCharacter(f) for f in self.friends] + return [get_character(f) for f in self.friends] class Human(Character): @@ -43,15 +43,15 @@ class Query(graphene.ObjectType): @resolve_only_args def resolve_hero(self, episode=None): - return getHero(episode) + return get_hero(episode) @resolve_only_args def resolve_human(self, id): - return getHuman(id) + return get_human(id) @resolve_only_args def resolve_droid(self, id): - return getDroid(id) + return get_droid(id) Schema = graphene.Schema(query=Query)