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
评论列表
文章目录