graphql如何查询树形结构数据
发布于 4 年前 作者 zhsonga 5151 次浏览 来自 问答

定义的查询实体

const file = new GraphQLObjectType({
    name: "file",
    fields: () => ({
        children: { type: new GraphQLList(file) },
        path: { type: GraphQLString },
        parent_id: { type: GraphQLString },
        id: { type: GraphQLString },
        is_dir: { type: GraphQLInt },
        name: { type: GraphQLString }
    })
});

查询语句跟返回结果 image.png

正常数据 image.png

这种树形结构的数据肯定不能写死吧 有的时候并不知道层级多深啊 大佬们有啥解决办法嘛:)

2 回复

@iyangsheng 谢谢大佬 这样感觉不如把原始数据传到前端让前端生成树结构了

回到顶部