Search code examples
graphqlgatsbymdx

Gatsby 5 - get fileAbsolutePath for a node


After migrating my project to Gatsby 5 I'm no longer able to access fileAbsolutePath on nodes returned by this query:

allMdx {
  nodes {
    id
    frontmatter {
      name
      type
    }
    fileAbsolutePath // Does not exist
  }
}

My understanding is that the schema has changed. Unable to find relevant information regarding where to find the respective data.

I tried:

allMdx {
  nodes {
    id
    frontmatter {
      name
      type
    }
    file {
      absoluteParth
    }
  }
}

But I'm seeing this error:

gatsby-plugin-local-search - The provided GraphQL query contains errors. The index will not be created. Cannot query field "file" on type "Mdx".

GraphQLError: Cannot query field "file" on type "Mdx".

Solution

  • According to gatsby-plugin-mdx, alternative to fileAbsolutePath is

    internal.contentFilePath The absolute path to the MDX file (useful for passing it to ?__contentFilePath query param for layouts). Equivalent to the absolutePath on File nodes.