title: Gatsby related contents
body: <p>I'm making a site with Gatsby.
  I've several Mdx pages. Some of these pages are &quot;related&quot; each other (by <em>slug</em>).
  For example:</p>
  <pre><code>pageone.mdx
     -- frontmatter --
     image: &quot;team.jpg&quot;
  
  pagetwo.mdx
     -- frontmatter --
     image: &quot;second.jpg&quot;
     relateds:
      - pagetwo
  </code></pre>
  <p>An extract of my gatsby-node.js</p>
  <pre><code>const path = require(`path`)
  const { createFilePath } = require(`gatsby-source-filesystem`)
  
  exports.onCreateWebpackConfig = ({  
      stage,
      rules,
      loaders,
      plugins,
      actions, }) =&gt; {
          actions.setWebpackConfig({
              module: {
  
              },
              plugins: [
                plugins.define({
                  __DEVELOPMENT__: stage === `develop` || stage === `develop-html`,
                }),
              ],
              node: {
                fs: &quot;empty&quot;,
              },
            })
    }
  
  exports.onCreateNode = ({ node, getNode, actions }) =&gt; {
    const { createNodeField } = actions
    if (node.internal.type === `Mdx`) {
      const value = createFilePath({ node, getNode })
      const image = node.frontmatter.image
  
      createNodeField({
        node,
        name: `slug`,
        value: value,
      })
      createNodeField({
        node,
        name: `image`,
        value: image,
      })
  
    }
  }
  exports.createPages = async ({ graphql, actions , reporter}) =&gt; {
    const { createPage } = actions
    const result = await graphql(`
      query {
        allMdx {
          edges {
            node {
              id
              fields {
                slug
                image
                
              }
            }
          }
        }
      }
    `)
    if (result.errors) {
      reporter.panicOnBuild('  ERROR: Loading &quot;createPages&quot; query')
    }
  
    const pages = result.data.allMdx.edges
  
    pages.forEach(({ node }, index) =&gt; {
      createPage({
        path: node.fields.slug,
        component: path.resolve(`./src/templates/mdTemplate.js`),
        context: { id: node.id, 
                   image: node.fields.image },
        })
    })
  }
  
  
  exports.createSchemaCustomization = ({ actions }) =&gt; {
    const { createTypes } = actions
    const typeDefs = `
      type Mdx implements Node {
        image: String,
        relateds: [Mdx] @link(by: &quot;slug&quot;, from: &quot;relateds&quot;)
      }
  
    `
    createTypes(typeDefs)
  }
  </code></pre>
  <p>My aim is to obtain for each node a &quot;related contents&quot; of him.</p>
  <p>White the code above I've a &quot;relateds&quot; field for each mdx node but If I explore with graphql client I obtain : <em>null</em></p>