【发布时间】:2022-01-10 18:03:46
【问题描述】:
我有这个解析器查询,我在其中过滤所有降价条目以构建一个集合:
export const createResolvers = ({createResolvers}) => {
const resolvers = {
Query : {
allPosts : {
type : ["Post"],
args : { limit: `Int`, skip: `Int` },
resolve: async (source, args, context, info) => {
const { entries } = await context.nodeModel.findAll({
type : "MarkdownRemark",
query: {
limit : args.limit,
skip : args.skip,
filter: {
fileAbsolutePath: {
regex: "//collections/posts//"
}
}
}
});
return entries;
}
},
}
}
}
它返回一个Post类型的集合:
type Post implements Node @dontInfer {
id: ID!
html: String
rawMarkdownBody: String
fileAbsolutePath: String
...
}
我选择的MarkdownRemark 条目有一个html 字段,其中包含markdown 文件的html 输出。我可以在 Graphiql 游乐场/控制台中看到它。
当我使用allPosts 查询时,html 字段为空。我得到rawMarkdownBody 和其他字段,但没有得到html。
有什么想法吗?
【问题讨论】: