微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

石墨烯 + GraphQl如何修复错误:“类型为 \"*GQL\" 的预期值但得到:*."?

如何解决石墨烯 + GraphQl如何修复错误:“类型为 \"*GQL\" 的预期值但得到:*."?

sqlAlchemy 中的数据模式级别,所有表都通过关系链接我有以下 GraphQL 数据架构:

class CategoryGQL(sqlAlchemyObjectType):
    class Meta:
        proxy = True
        description = "Table of category"
        model = CategoryModel
        interfaces = [relay.Node]

class DOOPGQL(sqlAlchemyObjectType):
    class Meta:
        proxy = True
        description = "Table of DOOP"
        model = DOOPModel
        interfaces = (relay.Node,)

class DirectionGQL(sqlAlchemyObjectType):
    class Meta:
        description = "Table of direction"
        model = DirectionModel
        interfaces = [relay.Node]

class Category_DOOPGQL(sqlAlchemyObjectType):
    class Meta:
        description = "Category and Doop relationship table"
        model = Category_DOOP_Model
        interfaces = (relay.Node,)

我也实现了这个解析器。我收到错误:收到不兼容的实例,如果我没有将 lambda 与第一个参数 graphene.List() 一起使用:

class AdvancedSearch(ObjectType):
    age = List(graphene.NonNull(graphene.String))  # [Array!]
    direction = List(graphene.NonNull(graphene.String))  # [Array!]
    ovz = graphene.Boolean()

    doops = graphene.List(lambda: graphene.List(DOOPGQL),ovz=ovz,age=age,direction=direction)
    
    def resolve_doops(self,info):
        query = db.query(DOOP,Direction,Category,Category_DOOP)
        query = query.filter_by(ovz=self.ovz)
        query = query.join(Direction,Direction.id_cluster == DOOP.id_cluster)
        query = query.filter(Direction.name.in_(self.direction))
        query = query.join(Category_DOOP,Category_DOOP.id_doop == DOOP.id)
        query = query.join(Category,Category_DOOP.id_category == Category.id)
        query = query.filter(Category.age_max.in_(self.age),Category.age_min.in_(self.age))
        query = query.all()
        return query

我得到了这个答案:

 "errors": [
    {
      "message": "Expected value of type \"DOOPGQL\" but got: Direction.","locations": [
        {
          "line": 3,"column": 5
        }
      ]
    },{
      "message": "Expected value of type \"DOOPGQL\" but got: Category.",{
      "message": "Expected value of type \"DOOPGQL\" but got: Category_DOOP.","column": 5
        }
      ]
    }
  ]

我该如何解决这个问题?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。