{"action":"created","issue":{"url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/7251","repository_url":"https://api.github.com/repos/gatsbyjs/gatsby","labels_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/7251/labels{/name}","comments_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/7251/comments","events_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/7251/events","html_url":"https://github.com/gatsbyjs/gatsby/issues/7251","id":349764960,"node_id":"MDU6SXNzdWUzNDk3NjQ5NjA=","number":7251,"title":"How to query all posts by an author when you have multiple authors per post","user":{"login":"gurtjun","id":13830735,"node_id":"MDQ6VXNlcjEzODMwNzM1","avatar_url":"https://avatars3.githubusercontent.com/u/13830735?v=4","gravatar_id":"","url":"https://api.github.com/users/gurtjun","html_url":"https://github.com/gurtjun","followers_url":"https://api.github.com/users/gurtjun/followers","following_url":"https://api.github.com/users/gurtjun/following{/other_user}","gists_url":"https://api.github.com/users/gurtjun/gists{/gist_id}","starred_url":"https://api.github.com/users/gurtjun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gurtjun/subscriptions","organizations_url":"https://api.github.com/users/gurtjun/orgs","repos_url":"https://api.github.com/users/gurtjun/repos","events_url":"https://api.github.com/users/gurtjun/events{/privacy}","received_events_url":"https://api.github.com/users/gurtjun/received_events","type":"User","site_admin":false},"labels":[{"id":1038048834,"node_id":"MDU6TGFiZWwxMDM4MDQ4ODM0","url":"https://api.github.com/repos/gatsbyjs/gatsby/labels/status:%20confirmed","name":"status: confirmed","color":"adff60","default":false},{"id":214544672,"node_id":"MDU6TGFiZWwyMTQ1NDQ2NzI=","url":"https://api.github.com/repos/gatsbyjs/gatsby/labels/type:%20bug","name":"type: bug","color":"d93f0b","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-08-11T21:28:04Z","updated_at":"2018-10-14T18:41:59Z","closed_at":null,"author_association":"NONE","body":"<!--\r\n  To make it easier for us to help you, please include as much useful information as possible.\r\n\r\n  Useful Links:\r\n  - Documentation: https://www.gatsbyjs.org/docs/\r\n\r\n  Gatsby has several community support channels, try asking your question on:\r\n\r\n  - Discord: https://discord.gg/0ZcbPKXt5bVoxkfV\r\n  - Spectrum: https://spectrum.chat/gatsby-js\r\n  - Twitter: https://twitter.com/gatsbyjs\r\n\r\n  Before opening a new issue, please search existing issues https://github.com/gatsbyjs/gatsby/issues\r\n-->\r\n\r\n## Summary\r\n\r\nI'm working on a blog where one blogpost can have multiple authors. I got this working with [mappings between my nodes](https://next.gatsbyjs.org/docs/gatsby-config/#mapping-node-types). I can query for a markdown file and get all the linked authors. \r\n\r\nNow I'm working on a page for each author that displays all the posts he/she contributed to. How can this be done? Below you can find the query I'm currently using, but that one's not working (`author.js`).\r\n\r\nI setup an example in [this repo](https://github.com/gurtjun/gatsby-multiple-authors).\r\n## Relevant information\r\n\r\n<!-- Provide as much useful information as you can -->\r\n\r\n### File contents\r\n`gatsby-config.js`: \r\n```\r\nmodule.exports = {\r\n  ...\r\n  mapping: {\r\n    \"MarkdownRemark.frontmatter.authors\": `AuthorYaml`,\r\n  },\r\n  ...\r\n}\r\n```\r\n`gatsby-node.js`: \r\n```\r\nconst path = require(`path`)\r\nconst { createFilePath } = require(`gatsby-source-filesystem`)\r\n\r\nexports.onCreateNode = ({ node, getNode, actions }) => {\r\n  const { createNodeField } = actions\r\n  if (node.internal.type === `AuthorYaml`) {\r\n    const slug = createFilePath({ node, getNode, basePath: `data` })\r\n    createNodeField({\r\n      node,\r\n      name: `slug`,\r\n      value: slug,\r\n    })\r\n  }\r\n}\r\n\r\nexports.createPages = ({ graphql, actions }) => {\r\n  const { createPage } = actions\r\n  return new Promise((resolve, reject) => {\r\n    graphql(`\r\n        allAuthorYaml {\r\n          edges {\r\n            node {\r\n              id\r\n              fields {\r\n                slug\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    `).then(result => {\r\n      result.data.allAuthorYaml.edges.forEach(({ node }) => {\r\n        createPage({\r\n          path: node.fields.slug,\r\n          component: path.resolve(`./src/templates/author.js`),\r\n          context: {\r\n            // Data passed to context is available\r\n            // in page queries as GraphQL variables.\r\n            slug: node.fields.slug,\r\n            id: node.id\r\n          },\r\n        })\r\n      })\r\n      resolve()\r\n    })\r\n  })\r\n}\r\n```\r\n\r\n`src/pages/blog/example-blog-post.md`\r\n```\r\n---\r\ntitle: \"Example Blog Post\"\r\ndate: \"2018-08-11\"\r\nauthors: [john_doe, jane_doe]\r\n---\r\n```\r\n\r\n`src/data/author.yaml`\r\n```\r\n- id: john_doe\r\n  name: John Doe\r\n- id: jane_doe\r\n  name: Jane Doe\r\n```\r\n\r\n`src/templates/author.js`\r\n```\r\n...\r\nexport const query = graphql`\r\n  query($id: String!) {\r\n    allMarkdownRemark(filter: { frontmatter: { authors: { in: [$id] } } } ) {\r\n      edges {\r\n        node {\r\n          ...\r\n          html\r\n          ...\r\n        }\r\n      }\r\n    }\r\n  }\r\n`\r\n```"},"comment":{"url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/comments/429651084","html_url":"https://github.com/gatsbyjs/gatsby/issues/7251#issuecomment-429651084","issue_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/7251","id":429651084,"node_id":"MDEyOklzc3VlQ29tbWVudDQyOTY1MTA4NA==","user":{"login":"pieh","id":419821,"node_id":"MDQ6VXNlcjQxOTgyMQ==","avatar_url":"https://avatars1.githubusercontent.com/u/419821?v=4","gravatar_id":"","url":"https://api.github.com/users/pieh","html_url":"https://github.com/pieh","followers_url":"https://api.github.com/users/pieh/followers","following_url":"https://api.github.com/users/pieh/following{/other_user}","gists_url":"https://api.github.com/users/pieh/gists{/gist_id}","starred_url":"https://api.github.com/users/pieh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pieh/subscriptions","organizations_url":"https://api.github.com/users/pieh/orgs","repos_url":"https://api.github.com/users/pieh/repos","events_url":"https://api.github.com/users/pieh/events{/privacy}","received_events_url":"https://api.github.com/users/pieh/received_events","type":"User","site_admin":false},"created_at":"2018-10-14T18:41:59Z","updated_at":"2018-10-14T18:41:59Z","author_association":"CONTRIBUTOR","body":"Problem here is we don't create proper filter schema for mapped fields - we need to add support for that"}}
{"actor":{"display_login":"pieh"}}