special_fields.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:graphene-mongo 作者: joaovitorsilvestre 项目源码 文件源码
def list_field(f_name, mongo_field):
    from graphene_mongo import MongoSchema
    from graphene_mongo.fields.respective import respective_fields

    list_items_type = type(mongo_field.field)

    if list_items_type in respective_fields:
        return graphene.List(type(respective_fields[list_items_type]()))
    else:
        try:
            document = mongo_field.field.document_type
        except AttributeError:
            raise AttributeError('Error in {} field, have sure that this is defined with a mongoengine field'
                                 .format(f_name))

        schema = MongoSchema.get_or_generate_schema(document).schema
        return graphene.List(schema)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号