Skip to content

Commit 1c97eb6

Browse files
committed
chore: Add patch to schema to ensure the path field is always defined
1 parent e3ce678 commit 1c97eb6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

gatsby-node.js

+21
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@ const kebabCase = (string) =>
99
.replace(/\s+/g, '-')
1010
.toLowerCase();
1111

12+
// This is a temporary customization to ensure that the path field is always
13+
// queryable from the createPages API. We rely on the path for deprecation
14+
// warnings to inform authors that path is no longer a supported markdown
15+
// property. Because of Gatsby's type inference from frontmatter properties, the
16+
// query in createPages fails without this patch if no file contains a 'path'
17+
// frontmatter property.
18+
//
19+
// This patch can be safely removed when removing the deprecation warning in
20+
// createPages.
21+
exports.createSchemaCustomization = ({ actions }) => {
22+
const { createTypes } = actions;
23+
24+
const typeDefs = `
25+
type MdxFrontmatter {
26+
path: String
27+
}
28+
`;
29+
30+
createTypes(typeDefs);
31+
};
32+
1233
exports.createPages = async ({ actions, graphql, reporter }) => {
1334
const { createPage, createRedirect } = actions;
1435

0 commit comments

Comments
 (0)