Graphene-Django - 'int' object has no attribute 'pk'
I'm new to working with GraphQL and Django and I am trying to test out in the playground but I am getting a 'int' object has no attribute 'pk' error.
class Managers(models.Model): id = models.IntegerField(primary_key=True) jointed_time = models.DateField() started_event = models.IntegerField() favourite_team = models.ForeignKey( Teams, models.DO_NOTHING, db_column='favourite_team', blank=True, null=True) player_first_name = models.TextField() player_last_name = models.TextField() player_region_id = models.IntegerField() player_region_name = models.TextField() player_region_iso_code_short = models.TextField() player_region_iso_code_long = models.TextField() team_name = models.TextField() class Meta: managed = False db_table = 'managers' class Gameweeks(models.Model): id = models.IntegerField(primary_key=True) name = models.TextField() deadline_time = models.DateField() deadline_time_epoch = models.IntegerField() class Meta: managed = False db_table = 'gameweeks' class ManagerGwStats(models.Model): id = models.OneToOneField(Managers, models.DO_NOTHING, db_column='id', primary_key=True) active_chip = models.TextField(blank=True, null=True) gameweek = models.ForeignKey( Gameweeks, models.DO_NOTHING, db_column='gameweek') points = models.IntegerField() total_points = models.IntegerField() rank = models.IntegerField() rank_sort = models.IntegerField() overall_rank = models.IntegerField() bank = models.IntegerField() value = models.IntegerField() event_transfers = models.IntegerField() event_transfers_cost = models.IntegerField() points_on_bench = models.IntegerField() class Meta: managed = False db_table = 'manager_gw_stats' unique_together = (('id', 'gameweek'),)
class GameweekType(DjangoObjectType): class Meta: model = Gameweeks fields = "__all__" class ManagerType(DjangoObjectType): class Meta: model = Managers fields = "__all__" class ManagerGwStatType(DjangoObjectType): class Meta: model = ManagerGwStats fields = "__all__" class Query(graphene.ObjectType): all_managers = graphene.List(ManagerType) manager = graphene.Field(ManagerType, manager_id=graphene.Int()) all_gameweeks = graphene.List(GameweekType) gameweek = graphene.Field(GameweekType, gameweek=graphene.Int()) manager_gw_stats = graphene.Field(ManagerGwStatType, manager_id=graphene.Int(), gameweek=graphene.Int()) def resolve_all_managers(self, info): return Managers.objects.all() def resolve_manager(self, info, manager_id): return Managers.objects.get(pk=manager_id) def resolve_all_gameweeks(self, info): return Gameweeks.objects.all() def resolve_gameweek(self, info, gameweek): return Gameweeks.objects.get(pk=gameweek) def resolve_manager_gw_stats(self, info, manager_id, gameweek): return ManagerGwStats.objects.get(id=manager_id, gameweek=gameweek) schema = graphene.Schema(query=Query)
When I run some queries in the playground the managerGWStats query works until I try to delve into the ID field which is where I get the error. I am able to access gameweek data though which is why I am confused as the models for gameweeks and managers is broadly similar. I'm not sure if it has something to do with the composite PK I have on the ManagerGWStats model?