import graphene from graphene_django.types import DjangoObjectType from nba_app.models import Player, Team, State, City, HighSchool, College
class PlayerType(DjangoObjectType): class Meta: model = Player
class TeamType(DjangoObjectType): class Meta: model = Team
class StateType(DjangoObjectType): class Meta: model = State
class CityType(DjangoObjectType): class Meta: model = City
class HighSchoolType(DjangoObjectType): class Meta: model = HighSchool
class CollegeType(DjangoObjectType): class Meta: model = College
class Query(graphene.ObjectType): all_players = graphene.List(PlayerType) all_teams = graphene.List(TeamType) all_states = graphene.List(StateType) all_cities = graphene.List(CityType) all_highschools = graphene.List(HighSchoolType) all_colleges = graphene.List(CollegeType)
def resolve_all_players(self, info, **kwargs):
return Player.objects.all()
def resolve_all
type
Player
{
name
:
String