Graphql 如何将文章链接到作者

Graphql 如何将文章链接到作者,graphql,yaml,gatsby,relation,Graphql,Yaml,Gatsby,Relation,我正在尝试为每个作者生成一个页面,包括他们的所有帖子-以下是我的设置: 使用gatsby transformer yaml获取我的作者列表: 使用gatsby transformer remark获取我的帖子列表: 我的author节点正在我的frontmatter中成功映射,在我的gatsby config.js中使用它: 。。。 映射:{ “MarkdownRemark.frontmatter.author”:“AuthorsYaml”` }, ... 现在,我想做的是获得我

我正在尝试为每个作者生成一个页面,包括他们的所有帖子-以下是我的设置:

  • 使用
    gatsby transformer yaml
    获取我的作者列表:
  • 使用
    gatsby transformer remark
    获取我的帖子列表:
  • 我的
    author
    节点正在我的
    frontmatter
    中成功映射,在我的
    gatsby config.js
    中使用它:
。。。
映射:{
“MarkdownRemark.frontmatter.author”:“AuthorsYaml”`
},
...

现在,我想做的是获得我所有作者的帖子列表,使用如下内容:

    {
      allAuthorsYaml {
        nodes {
          id
          title
          posts {
            frontmatter {
              date
              location
              title
              slug
              tags
            }
            html
          }
        }
      }
    }
实现这一点最有效的方法是什么?遵循建议的GraphQL查询或其他最佳实践

谢谢

    {
      allFile(
        sort: { fields: childMarkdownRemark___frontmatter___date, order: DESC }
        filter: { sourceInstanceName: { eq: "posts" } }
      ) {
        edges {
          node {
            childMarkdownRemark {
              frontmatter {
                author {
                  title
                  id
                }
                date
                location
                title
                slug
                tags
              }
              html
            }
          }
        }
      }
    }
    {
      allAuthorsYaml {
        nodes {
          id
          title
          posts {
            frontmatter {
              date
              location
              title
              slug
              tags
            }
            html
          }
        }
      }
    }