Permalink
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (37 sloc) 901 Bytes
---
title: "Querying MDX Content via GraphQL"
---
MDX files sourced via `gatsby-source-filesystem` can be queried with
`allMdx` on the root query. Like `gatsby-transformer-remark`, `gatsby-mdx`
adds fields to the Mdx node including `excerpt`, `headings`,
`timeToRead`, and `wordCount`.
TODO: insert full GraphQL MDX Node Schema
All static exports – values that would be valid JSON – are queryable
through the `exports` field.
```graphql
query MDXQuery {
allMdx {
edges {
node {
parent {
... on File {
name
absolutePath
relativePath
}
}
timeToRead
frontmatter {
title
}
exports {
author
}
}
}
}
}
```
## Accessing Parents
MDX Nodes typically have a parent source.
TODO: explain `parent { ... on File { absolutePath} }` query fragments