在GraphQL Django的子架构中获取父ID

时间:2019-04-08 10:51:41

标签: python django django-rest-framework graphql graphene-python

我想在父模式中获得一个子类对象。

这是我的Models.py

class TeamType(DjangoObjectType):
    home = graphene.Field(TeamType)
    class Meta:
        model = Team

    def resolver_home(self, info):
        **# Here I want to get Bet object and perform some operations**
        if team.bet_id ==2:
            print("bet")   
        return team.bet

Class BetType(DjangoObjectType):
    home_team = graphene.Field(TeamType)

    class Meta:
        model = Bet

    def resolver_home_team(self, info):
      return self.event.team

Schema.py

// OPTION 1:

file) ParentA.vue

directory) ParentA

 |_ file) ParentAChildA.vue

在TeamType模式中,我想要下注对象,以便执行操作。 我也尝试了graphene.String(),但是没有帮助。

0 个答案:

没有答案