1

我在我的 Flask 应用程序(https://github.com/graphql-python/graphene-sqlalchemy)中使用了 graphene_sqlalchemy 包,我需要使用相同的模型进行两个查询。我想知道是否有可能两种类型共享相同的模型,如下所示:

class A(SQLAlchemyObjectType):
    x = graphene.Int()

    class Meta:
        model = Model
        interfaces = (graphene.relay.Node,)

class B(SQLAlchemyObjectType):
    y = graphene.Int()

    class Meta:
        model = Model
        interfaces = (graphene.relay.Node,)

或使用继承:

class A(SQLAlchemyObjectType):
    x = graphene.Int()

    class Meta:
        model = Model
        interfaces = (graphene.relay.Node,)

class B(A):
    y = graphene.Int()

但是我在使用这两种方法时遇到了错误。有什么解决方法吗?先感谢您 !

4

0 回答 0