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)
special_fields.py 文件源码
python
阅读 34
收藏 0
点赞 0
评论 0
评论列表
文章目录