def schema_builder():
def build(schemas, mutations=None):
mutations = [] if not mutations else mutations
attrs = {schema[0].model.__name__.lower(): schema[1] for schema in schemas}
Query = type('Query', (graphene.ObjectType,), attrs)
attrs = {'create_' + m.model.__name__.lower(): m.mutate for m in mutations}
Mutation = type('Mutation', (graphene.ObjectType,), attrs)
return graphene.Schema(query=Query, mutation=Mutation)
return build
评论列表
文章目录