respective.py 文件源码

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

项目:graphene-mongo 作者: joaovitorsilvestre 项目源码 文件源码
def field_to_id(m_field, g_field):
    """ We need this because if we want to do a query using the id, we will pass a string to args with the id of the 
    document that we want, but graphene needs a ID field, instead of Field. This function convert to right thing."""

    if isinstance(m_field, ReferenceField):
        return graphene.ID()
    elif (isinstance(m_field, ListField) or isinstance(m_field, SortedListField)) and \
            isinstance(m_field.field, ReferenceField):
        """ Pass here if it is a ListField or SortedListField of ReferenceField """
        return graphene.List(graphene.ID)
    else:
        return g_field
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号