From f262e97e58fe1cacb6bdf0d5b64a3f84f0469502 Mon Sep 17 00:00:00 2001 From: Lennart Date: Mon, 25 Jul 2022 15:24:32 +0200 Subject: [PATCH] MDX v2: Support FS routes (#36118) * add feature to flags * add contentFilePath to node.internal * add contentFilePath to query and change component in createPage * update snapshots * half-broken wip * fix weird error :D * remove export query param better * use better regex in replace * typo * add test --- .../src/parse-component-path.ts | 14 ++-- packages/gatsby-plugin-mdx/src/gatsby-node.ts | 3 +- .../collection-extract-query-string.ts | 40 +++++++--- .../src/__tests__/extract-query.ts | 76 ++++++++++++++----- .../create-pages-from-collection-builder.ts | 7 +- .../src/extract-query.ts | 8 +- .../components/runtime-errors.js | 2 +- packages/gatsby/index.d.ts | 3 +- packages/gatsby/scripts/__tests__/api.js | 1 + packages/gatsby/scripts/output-api-file.js | 2 +- .../gatsby/src/bootstrap/requires-writer.ts | 14 +++- packages/gatsby/src/joi-schemas/joi.ts | 1 + .../__snapshots__/build-schema.js.snap | 54 +++++++++++++ .../__snapshots__/rebuild-schema.js.snap | 61 +++++++++++++++ .../gatsby/src/schema/types/node-interface.ts | 1 + .../gatsby/src/utils/babel-loader-helpers.js | 10 ++- packages/gatsby/src/utils/js-chunk-names.ts | 2 - .../plugins/__tests__/static-query-mapper.ts | 31 ++++++++ .../webpack/plugins/static-query-mapper.ts | 23 +++++- 19 files changed, 301 insertions(+), 52 deletions(-) create mode 100644 packages/gatsby/src/utils/webpack/plugins/__tests__/static-query-mapper.ts diff --git a/packages/gatsby-core-utils/src/parse-component-path.ts b/packages/gatsby-core-utils/src/parse-component-path.ts index c6b0cd5387759..9ccae9dfe991b 100644 --- a/packages/gatsby-core-utils/src/parse-component-path.ts +++ b/packages/gatsby-core-utils/src/parse-component-path.ts @@ -12,21 +12,19 @@ export const splitComponentPath = (componentPath: string): Array => { return [componentPath] } - const splitPath = componentPath.split(CONTENT_FILE_PATH_QUERY) + const cleanedComponentPath = componentPath.replace( + /&export=(default|head)$/, + `` + ) + const splitPath = cleanedComponentPath.split(CONTENT_FILE_PATH_QUERY) // We only support URI paths with the `?__contentFilePath=` parameter if (splitPath.length !== 2) { throw new Error( - `The following page component must contain '${CONTENT_FILE_PATH_QUERY}':\n${componentPath}` + `The following page component must contain '${CONTENT_FILE_PATH_QUERY}':\n${cleanedComponentPath}` ) } - // Other URI parameters are not supported - if (splitPath[1].includes(`&`)) { - throw new Error( - `You can not pass any other parameters to a page component URI as 'contentFilePath'. Remove the ampersand (&):\n${componentPath}` - ) - } return splitPath } diff --git a/packages/gatsby-plugin-mdx/src/gatsby-node.ts b/packages/gatsby-plugin-mdx/src/gatsby-node.ts index 02aacab1ab7f2..4b4e63d9192e6 100644 --- a/packages/gatsby-plugin-mdx/src/gatsby-node.ts +++ b/packages/gatsby-plugin-mdx/src/gatsby-node.ts @@ -63,7 +63,7 @@ export const onCreateWebpackConfig: GatsbyNode["onCreateWebpackConfig"] = }, { test: /\.[tj]sx?$/, - resourceQuery: /__contentFilePath=.+\.mdx?$/, + resourceQuery: /__contentFilePath=.+\.mdx?(&export=.*)?$/, use: [ loaders.js(), { @@ -281,6 +281,7 @@ export const onCreateNode: GatsbyNode["onCreateNode"] = async ({ internal: { type: `Mdx`, contentDigest: node.internal.contentDigest, + contentFilePath: node.absolutePath, }, body, frontmatter, diff --git a/packages/gatsby-plugin-page-creator/src/__tests__/collection-extract-query-string.ts b/packages/gatsby-plugin-page-creator/src/__tests__/collection-extract-query-string.ts index c0e13cb3e9833..3a6bbd8d2bc89 100644 --- a/packages/gatsby-plugin-page-creator/src/__tests__/collection-extract-query-string.ts +++ b/packages/gatsby-plugin-page-creator/src/__tests__/collection-extract-query-string.ts @@ -36,7 +36,9 @@ describe(`collectionExtractQueryString`, () => { reporter ) - expect(query).toMatchInlineSnapshot(`"{allProduct{nodes{name,id}}}"`) + expect(query).toMatchInlineSnapshot( + `"{allProduct{nodes{name,id,internal{contentFilePath}}}}"` + ) }) it(`will create a basic query from the route with minimal length`, async () => { @@ -53,7 +55,9 @@ describe(`collectionExtractQueryString`, () => { reporter ) - expect(query).toMatchInlineSnapshot(`"{allP{nodes{n,id}}}"`) + expect(query).toMatchInlineSnapshot( + `"{allP{nodes{n,id,internal{contentFilePath}}}}"` + ) }) it(`will create a basic query from the route with a prefix variant 1`, async () => { @@ -70,7 +74,9 @@ describe(`collectionExtractQueryString`, () => { reporter ) - expect(query).toMatchInlineSnapshot(`"{allProduct{nodes{name,id}}}"`) + expect(query).toMatchInlineSnapshot( + `"{allProduct{nodes{name,id,internal{contentFilePath}}}}"` + ) }) it(`will create a basic query from the route with a prefix variant 2`, async () => { @@ -87,7 +93,9 @@ describe(`collectionExtractQueryString`, () => { reporter ) - expect(query).toMatchInlineSnapshot(`"{allProduct{nodes{name,id}}}"`) + expect(query).toMatchInlineSnapshot( + `"{allProduct{nodes{name,id,internal{contentFilePath}}}}"` + ) }) it(`will create a basic query from the route with a prefix variant 3`, async () => { @@ -104,7 +112,9 @@ describe(`collectionExtractQueryString`, () => { reporter ) - expect(query).toMatchInlineSnapshot(`"{allProduct{nodes{name,id}}}"`) + expect(query).toMatchInlineSnapshot( + `"{allProduct{nodes{name,id,internal{contentFilePath}}}}"` + ) }) it(`will create a basic query from the route with a postfix`, async () => { @@ -121,7 +131,9 @@ describe(`collectionExtractQueryString`, () => { reporter ) - expect(query).toMatchInlineSnapshot(`"{allProduct{nodes{name,id}}}"`) + expect(query).toMatchInlineSnapshot( + `"{allProduct{nodes{name,id,internal{contentFilePath}}}}"` + ) }) it(`will create a basic query with multiple entries`, async () => { @@ -138,7 +150,9 @@ describe(`collectionExtractQueryString`, () => { reporter ) - expect(query).toMatchInlineSnapshot(`"{allProduct{nodes{name,color,id}}}"`) + expect(query).toMatchInlineSnapshot( + `"{allProduct{nodes{name,color,id,internal{contentFilePath}}}}"` + ) }) it(`will create a basic query with multiple entries and different delimiters variant 1`, async () => { @@ -155,7 +169,9 @@ describe(`collectionExtractQueryString`, () => { reporter ) - expect(query).toMatchInlineSnapshot(`"{allProduct{nodes{name,color,id}}}"`) + expect(query).toMatchInlineSnapshot( + `"{allProduct{nodes{name,color,id,internal{contentFilePath}}}}"` + ) }) it(`will create a basic query with multiple entries and different delimiters variant 1`, async () => { @@ -172,7 +188,9 @@ describe(`collectionExtractQueryString`, () => { reporter ) - expect(query).toMatchInlineSnapshot(`"{allProduct{nodes{name,color,id}}}"`) + expect(query).toMatchInlineSnapshot( + `"{allProduct{nodes{name,color,id,internal{contentFilePath}}}}"` + ) }) it(`will create a basic query with multiple entries and different delimiters variant 1`, async () => { @@ -189,6 +207,8 @@ describe(`collectionExtractQueryString`, () => { reporter ) - expect(query).toMatchInlineSnapshot(`"{allProduct{nodes{name,color,id}}}"`) + expect(query).toMatchInlineSnapshot( + `"{allProduct{nodes{name,color,id,internal{contentFilePath}}}}"` + ) }) }) diff --git a/packages/gatsby-plugin-page-creator/src/__tests__/extract-query.ts b/packages/gatsby-plugin-page-creator/src/__tests__/extract-query.ts index 52f2782e07051..d2ad582e2bae5 100644 --- a/packages/gatsby-plugin-page-creator/src/__tests__/extract-query.ts +++ b/packages/gatsby-plugin-page-creator/src/__tests__/extract-query.ts @@ -15,7 +15,9 @@ describe(`extract query`, () => { `Thing`, compatiblePath(`/foo/bar/{Thing.id}.js`) ) - ).toBe(`{allThing{nodes{id}}}`) + ).toMatchInlineSnapshot( + `"{allThing{nodes{id,internal{contentFilePath}}}}"` + ) }) it(`handles lowercased model name`, () => { @@ -24,7 +26,9 @@ describe(`extract query`, () => { `contentfulType`, compatiblePath(`/foo/{contentfulType.id}.js`) ) - ).toBe(`{allContentfulType{nodes{id}}}`) + ).toMatchInlineSnapshot( + `"{allContentfulType{nodes{id,internal{contentFilePath}}}}"` + ) }) it(`handles model name with underscore`, () => { @@ -33,7 +37,9 @@ describe(`extract query`, () => { `_customType`, compatiblePath(`/foo/{_customType.id}.js`) ) - ).toBe(`{allCustomType{nodes{id}}}`) + ).toMatchInlineSnapshot( + `"{allCustomType{nodes{id,internal{contentFilePath}}}}"` + ) }) it(`handles model name with number`, () => { @@ -42,7 +48,9 @@ describe(`extract query`, () => { `Type123`, compatiblePath(`/foo/{Type123.id}.js`) ) - ).toBe(`{allType123{nodes{id}}}`) + ).toMatchInlineSnapshot( + `"{allType123{nodes{id,internal{contentFilePath}}}}"` + ) }) it(`handles fields with number or underscore`, () => { @@ -51,13 +59,17 @@ describe(`extract query`, () => { `_type123`, compatiblePath(`/foo/{_type123.field123}.js`) ) - ).toBe(`{allType123{nodes{field123,id}}}`) + ).toMatchInlineSnapshot( + `"{allType123{nodes{field123,id,internal{contentFilePath}}}}"` + ) expect( generateQueryFromString( `_type123`, compatiblePath(`/foo/{_type123._field123}.js`) ) - ).toBe(`{allType123{nodes{_field123,id}}}`) + ).toMatchInlineSnapshot( + `"{allType123{nodes{_field123,id,internal{contentFilePath}}}}"` + ) }) it(`works with different file extensions`, () => { @@ -66,7 +78,9 @@ describe(`extract query`, () => { `Thing`, compatiblePath(`/foo/bar/{Thing.id}.tsx`) ) - ).toBe(`{allThing{nodes{id}}}`) + ).toMatchInlineSnapshot( + `"{allThing{nodes{id,internal{contentFilePath}}}}"` + ) }) }) @@ -77,7 +91,9 @@ describe(`extract query`, () => { `Thing`, compatiblePath(`/foo/bar/{Thing.id}.js`) ) - ).toBe(`{allThing{nodes{id}}}`) + ).toMatchInlineSnapshot( + `"{allThing{nodes{id,internal{contentFilePath}}}}"` + ) }) it(`always queries id`, () => { @@ -86,7 +102,9 @@ describe(`extract query`, () => { `Thing`, compatiblePath(`/foo/bar/{Thing.baz}.js`) ) - ).toBe(`{allThing{nodes{baz,id}}}`) + ).toMatchInlineSnapshot( + `"{allThing{nodes{baz,id,internal{contentFilePath}}}}"` + ) }) it(`multiple nodes`, () => { @@ -95,13 +113,17 @@ describe(`extract query`, () => { `Thing`, compatiblePath(`/foo/bar/{Thing.id}/{Thing.name}.js`) ) - ).toBe(`{allThing{nodes{id,name}}}`) + ).toMatchInlineSnapshot( + `"{allThing{nodes{id,name,internal{contentFilePath}}}}"` + ) expect( generateQueryFromString( `Thing`, compatiblePath(`/foo/bar/{Thing.id}-{Thing.name}.js`) ) - ).toBe(`{allThing{nodes{id,name}}}`) + ).toMatchInlineSnapshot( + `"{allThing{nodes{id,name,internal{contentFilePath}}}}"` + ) }) it(`nested nodes`, () => { @@ -110,7 +132,9 @@ describe(`extract query`, () => { `Thing`, compatiblePath(`/foo/bar/{Thing.id}/{Thing.fields__name}.js`) ) - ).toBe(`{allThing{nodes{id,fields{name}}}}`) + ).toMatchInlineSnapshot( + `"{allThing{nodes{id,fields{name},internal{contentFilePath}}}}"` + ) }) it(`multiple nested nodes`, () => { @@ -121,7 +145,9 @@ describe(`extract query`, () => { `/foo/bar/{thing.fields__name}/{thing.fields__description}.js` ) ) - ).toBe(`{allThing{nodes{fields{name},fields{description},id}}}`) + ).toMatchInlineSnapshot( + `"{allThing{nodes{fields{name},fields{description},id,internal{contentFilePath}}}}"` + ) }) it(`deeply nested nodes`, () => { @@ -130,7 +156,9 @@ describe(`extract query`, () => { `Thing`, compatiblePath(`/foo/bar/{Thing.id}/{Thing.fields__name__thing}.js`) ) - ).toBe(`{allThing{nodes{id,fields{name{thing}}}}}`) + ).toMatchInlineSnapshot( + `"{allThing{nodes{id,fields{name{thing}},internal{contentFilePath}}}}"` + ) expect( generateQueryFromString( `customType`, @@ -138,7 +166,9 @@ describe(`extract query`, () => { `/foo/bar/{customType.id}/{customType.fields__name__thing}.js` ) ) - ).toBe(`{allCustomType{nodes{id,fields{name{thing}}}}}`) + ).toMatchInlineSnapshot( + `"{allCustomType{nodes{id,fields{name{thing}},internal{contentFilePath}}}}"` + ) }) it(`deeply nested nodes with prefixes`, () => { @@ -149,7 +179,9 @@ describe(`extract query`, () => { `/foo/bar/prefix-{Thing.id}/another-prefix_{Thing.fields__name__thing}.js` ) ) - ).toBe(`{allThing{nodes{id,fields{name{thing}}}}}`) + ).toMatchInlineSnapshot( + `"{allThing{nodes{id,fields{name{thing}},internal{contentFilePath}}}}"` + ) }) it(`deeply nested nodes with postfixes`, () => { @@ -160,7 +192,9 @@ describe(`extract query`, () => { `/foo/bar/{Thing.id}-postfix/{Thing.fields__name__thing}_another-postfix.js` ) ) - ).toBe(`{allThing{nodes{id,fields{name{thing}}}}}`) + ).toMatchInlineSnapshot( + `"{allThing{nodes{id,fields{name{thing}},internal{contentFilePath}}}}"` + ) }) it(`supports graphql unions`, () => { @@ -171,7 +205,9 @@ describe(`extract query`, () => { `/foo/bar/{UnionQuery.id}/{UnionQuery.parent__(File)__relativePath}.js` ) ) - ).toBe(`{allUnionQuery{nodes{id,parent{... on File{relativePath}}}}}`) + ).toMatchInlineSnapshot( + `"{allUnionQuery{nodes{id,parent{... on File{relativePath}},internal{contentFilePath}}}}"` + ) }) it(`supports nested graphql unions`, () => { @@ -182,8 +218,8 @@ describe(`extract query`, () => { `/foo/bar/{UnionQuery.id}/{UnionQuery.parent__(File)__parent__(Bar)__relativePath}.js` ) ) - ).toBe( - `{allUnionQuery{nodes{id,parent{... on File{parent{... on Bar{relativePath}}}}}}}` + ).toMatchInlineSnapshot( + `"{allUnionQuery{nodes{id,parent{... on File{parent{... on Bar{relativePath}}}},internal{contentFilePath}}}}"` ) }) }) diff --git a/packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts b/packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts index 21ef8ad26ef3e..6ace50dbc786a 100644 --- a/packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts +++ b/packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts @@ -116,6 +116,7 @@ ${errors.map(error => error.message).join(`\n`)}`.trim(), // the watcher will use this data to delete the pages if the query changes significantly. const paths: Array = [] nodes.forEach((node: Record>) => { + const contentFilePath = node.internal?.contentFilePath // URL path for the component and node const { derivedPath, errors } = derivePath( filePath, @@ -141,10 +142,14 @@ ${errors.map(error => error.message).join(`\n`)}`.trim(), const modifiedPath = applyTrailingSlashOption(path, trailingSlash) + const componentPath = contentFilePath + ? `${absolutePath}?__contentFilePath=${contentFilePath}` + : absolutePath + actions.createPage({ path: modifiedPath, matchPath, - component: absolutePath, + component: componentPath, context: { ...nodeParams, __params: params, diff --git a/packages/gatsby-plugin-page-creator/src/extract-query.ts b/packages/gatsby-plugin-page-creator/src/extract-query.ts index 6487352ee3335..b9e738248af8e 100644 --- a/packages/gatsby-plugin-page-creator/src/extract-query.ts +++ b/packages/gatsby-plugin-page-creator/src/extract-query.ts @@ -1,3 +1,4 @@ +import { hasFeature } from "gatsby-plugin-utils" import _ from "lodash" import path from "path" import { @@ -52,7 +53,7 @@ export function reverseLookupParams( return reversedParams } -// Changes something like `/Users/site/src/pages/foo/{Model.id}/{Model.baz}` to `id,baz`. +// Changes something like `/Users/site/src/pages/foo/{Model.id}/{Model.baz}` to `id,baz,internal{contentFilePath}`. // Also supports prefixes/postfixes, e.g. `/foo/prefix-{Model.id}` to `id` function extractUrlParamsForQuery(createdPath: string): string { const parts = createdPath.split(path.sep) @@ -62,6 +63,11 @@ function extractUrlParamsForQuery(createdPath: string): string { parts.push(`{Model.id}`) } + // Always add internal { contentFilePath } if feature is available + if (hasFeature(`content-file-path`)) { + parts.push(`{Model.internal__contentFilePath}`) + } + return parts .reduce>( (queryParts: Array, part: string): Array => { diff --git a/packages/gatsby/cache-dir/fast-refresh-overlay/components/runtime-errors.js b/packages/gatsby/cache-dir/fast-refresh-overlay/components/runtime-errors.js index 6957e435603ae..0054010069e4f 100644 --- a/packages/gatsby/cache-dir/fast-refresh-overlay/components/runtime-errors.js +++ b/packages/gatsby/cache-dir/fast-refresh-overlay/components/runtime-errors.js @@ -15,7 +15,7 @@ function WrappedAccordionItem({ error, open }) { const columnNumber = codeFrameInformation?.columnNumber const name = codeFrameInformation?.functionName // With the introduction of Metadata management the modulePath can have a resourceQuery that needs to be removed first - const filePath = modulePath.replace(/\?export=(default|head)$/, ``) + const filePath = modulePath.replace(/(\?|&)export=(default|head)$/, ``) const res = useStackFrame({ moduleId: modulePath, lineNumber, columnNumber }) const line = res.sourcePosition?.line diff --git a/packages/gatsby/index.d.ts b/packages/gatsby/index.d.ts index 0d5535869d64e..b7ca9d2aac391 100644 --- a/packages/gatsby/index.d.ts +++ b/packages/gatsby/index.d.ts @@ -17,7 +17,7 @@ import { GraphQLOutputType } from "graphql" import { PluginOptionsSchemaJoi, ObjectSchema } from "gatsby-plugin-utils" import { IncomingMessage, ServerResponse } from "http" -export type AvailableFeatures = "image-cdn" | "graphql-typegen" +export type AvailableFeatures = "image-cdn" | "graphql-typegen" | "content-file-path" export { default as Link, @@ -1633,6 +1633,7 @@ export interface NodeInput { content?: string contentDigest: string description?: string + contentFilePath?: string } [key: string]: unknown } diff --git a/packages/gatsby/scripts/__tests__/api.js b/packages/gatsby/scripts/__tests__/api.js index 6640eb77218c4..477f2e51bce7b 100644 --- a/packages/gatsby/scripts/__tests__/api.js +++ b/packages/gatsby/scripts/__tests__/api.js @@ -33,6 +33,7 @@ it("generates the expected api output", done => { "features": Array [ "image-cdn", "graphql-typegen", + "content-file-path", ], "node": Object { "createPages": Object {}, diff --git a/packages/gatsby/scripts/output-api-file.js b/packages/gatsby/scripts/output-api-file.js index f2b8f7638ec7b..5ab27191f2810 100644 --- a/packages/gatsby/scripts/output-api-file.js +++ b/packages/gatsby/scripts/output-api-file.js @@ -41,7 +41,7 @@ async function outputFile() { }, {}) /** @type {Array} */ - output.features = ["image-cdn", "graphql-typegen"]; + output.features = ["image-cdn", "graphql-typegen", "content-file-path"]; return fs.writeFile( path.resolve(OUTPUT_FILE_NAME), diff --git a/packages/gatsby/src/bootstrap/requires-writer.ts b/packages/gatsby/src/bootstrap/requires-writer.ts index bcc9e7795a3b7..09aec94c998cb 100644 --- a/packages/gatsby/src/bootstrap/requires-writer.ts +++ b/packages/gatsby/src/bootstrap/requires-writer.ts @@ -38,6 +38,8 @@ const ROOT_POINTS = 1 const isRootSegment = (segment: string): boolean => segment === `` const isDynamic = (segment: string): boolean => paramRe.test(segment) const isSplat = (segment: string): boolean => segment === `*` +const hasContentFilePath = (componentPath: string): boolean => + componentPath.includes(`?__contentFilePath=`) const segmentize = (uri: string): Array => uri @@ -259,9 +261,13 @@ const preferDefault = m => (m && m.default) || m c.component ) + const rqPrefix = hasContentFilePath(relativeComponentPath) ? `&` : `?` + return ` "${c.componentChunkName}": () => import("${slash( `./${relativeComponentPath}` - )}?export=default" /* webpackChunkName: "${c.componentChunkName}" */)` + )}${rqPrefix}export=default" /* webpackChunkName: "${ + c.componentChunkName + }" */)` }) .join(`,\n`)} }\n\n @@ -274,9 +280,13 @@ exports.head = {\n${components c.component ) + const rqPrefix = hasContentFilePath(relativeComponentPath) ? `&` : `?` + return ` "${c.componentChunkName}": () => import("${slash( `./${relativeComponentPath}` - )}?export=head" /* webpackChunkName: "${c.componentChunkName}head" */)` + )}${rqPrefix}export=head" /* webpackChunkName: "${ + c.componentChunkName + }head" */)` }) .join(`,\n`)} }\n\n` diff --git a/packages/gatsby/src/joi-schemas/joi.ts b/packages/gatsby/src/joi-schemas/joi.ts index eb36eef8dde40..8e953ac7ebb85 100644 --- a/packages/gatsby/src/joi-schemas/joi.ts +++ b/packages/gatsby/src/joi-schemas/joi.ts @@ -134,6 +134,7 @@ export const nodeSchema: Joi.ObjectSchema = Joi.object() description: Joi.string(), ignoreType: Joi.boolean(), counter: Joi.number(), + contentFilePath: Joi.string(), }) .unknown(false), // Don't allow non-standard fields }) diff --git a/packages/gatsby/src/schema/__tests__/__snapshots__/build-schema.js.snap b/packages/gatsby/src/schema/__tests__/__snapshots__/build-schema.js.snap index 551fc1c293fb2..ddc3774f5200f 100644 --- a/packages/gatsby/src/schema/__tests__/__snapshots__/build-schema.js.snap +++ b/packages/gatsby/src/schema/__tests__/__snapshots__/build-schema.js.snap @@ -214,6 +214,7 @@ type Internal { mediaType: String owner: String! type: String! + contentFilePath: String } \\"\\"\\" @@ -553,6 +554,7 @@ input InternalFilterInput { mediaType: StringQueryOperatorInput owner: StringQueryOperatorInput type: StringQueryOperatorInput + contentFilePath: StringQueryOperatorInput } input BooleanQueryOperatorInput { @@ -638,6 +640,7 @@ enum FileFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -653,6 +656,7 @@ enum FileFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -661,6 +665,7 @@ enum FileFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -677,6 +682,7 @@ enum FileFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -692,6 +698,7 @@ enum FileFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -700,6 +707,7 @@ enum FileFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -708,6 +716,7 @@ enum FileFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type FileGroupConnection { @@ -838,6 +847,7 @@ enum DirectoryFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -853,6 +863,7 @@ enum DirectoryFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -861,6 +872,7 @@ enum DirectoryFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -877,6 +889,7 @@ enum DirectoryFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -892,6 +905,7 @@ enum DirectoryFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -900,6 +914,7 @@ enum DirectoryFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -908,6 +923,7 @@ enum DirectoryFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type DirectoryGroupConnection { @@ -1010,6 +1026,7 @@ enum SiteFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -1025,6 +1042,7 @@ enum SiteFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -1033,6 +1051,7 @@ enum SiteFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -1049,6 +1068,7 @@ enum SiteFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -1064,6 +1084,7 @@ enum SiteFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -1072,6 +1093,7 @@ enum SiteFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -1080,6 +1102,7 @@ enum SiteFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type SiteGroupConnection { @@ -1152,6 +1175,7 @@ enum SiteFunctionFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -1167,6 +1191,7 @@ enum SiteFunctionFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -1175,6 +1200,7 @@ enum SiteFunctionFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -1191,6 +1217,7 @@ enum SiteFunctionFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -1206,6 +1233,7 @@ enum SiteFunctionFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -1214,6 +1242,7 @@ enum SiteFunctionFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -1222,6 +1251,7 @@ enum SiteFunctionFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type SiteFunctionGroupConnection { @@ -1331,6 +1361,7 @@ enum SitePageFieldsEnum { pluginCreator___parent___internal___mediaType pluginCreator___parent___internal___owner pluginCreator___parent___internal___type + pluginCreator___parent___internal___contentFilePath pluginCreator___children pluginCreator___children___id pluginCreator___children___parent___id @@ -1346,6 +1377,7 @@ enum SitePageFieldsEnum { pluginCreator___children___internal___mediaType pluginCreator___children___internal___owner pluginCreator___children___internal___type + pluginCreator___children___internal___contentFilePath pluginCreator___internal___content pluginCreator___internal___contentDigest pluginCreator___internal___description @@ -1354,6 +1386,7 @@ enum SitePageFieldsEnum { pluginCreator___internal___mediaType pluginCreator___internal___owner pluginCreator___internal___type + pluginCreator___internal___contentFilePath id parent___id parent___parent___id @@ -1370,6 +1403,7 @@ enum SitePageFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -1385,6 +1419,7 @@ enum SitePageFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -1393,6 +1428,7 @@ enum SitePageFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -1409,6 +1445,7 @@ enum SitePageFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -1424,6 +1461,7 @@ enum SitePageFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -1432,6 +1470,7 @@ enum SitePageFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -1440,6 +1479,7 @@ enum SitePageFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type SitePageGroupConnection { @@ -1519,6 +1559,7 @@ enum SitePluginFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -1534,6 +1575,7 @@ enum SitePluginFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -1542,6 +1584,7 @@ enum SitePluginFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -1558,6 +1601,7 @@ enum SitePluginFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -1573,6 +1617,7 @@ enum SitePluginFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -1581,6 +1626,7 @@ enum SitePluginFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -1589,6 +1635,7 @@ enum SitePluginFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type SitePluginGroupConnection { @@ -1646,6 +1693,7 @@ enum SiteBuildMetadataFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -1661,6 +1709,7 @@ enum SiteBuildMetadataFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -1669,6 +1718,7 @@ enum SiteBuildMetadataFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -1685,6 +1735,7 @@ enum SiteBuildMetadataFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -1700,6 +1751,7 @@ enum SiteBuildMetadataFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -1708,6 +1760,7 @@ enum SiteBuildMetadataFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -1716,6 +1769,7 @@ enum SiteBuildMetadataFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type SiteBuildMetadataGroupConnection { diff --git a/packages/gatsby/src/schema/__tests__/__snapshots__/rebuild-schema.js.snap b/packages/gatsby/src/schema/__tests__/__snapshots__/rebuild-schema.js.snap index bb1ea4b22e958..a291a14a98110 100644 --- a/packages/gatsby/src/schema/__tests__/__snapshots__/rebuild-schema.js.snap +++ b/packages/gatsby/src/schema/__tests__/__snapshots__/rebuild-schema.js.snap @@ -214,6 +214,7 @@ type Internal { mediaType: String owner: String! type: String! + contentFilePath: String } \\"\\"\\" @@ -553,6 +554,7 @@ input InternalFilterInput { mediaType: StringQueryOperatorInput owner: StringQueryOperatorInput type: StringQueryOperatorInput + contentFilePath: StringQueryOperatorInput } input BooleanQueryOperatorInput { @@ -638,6 +640,7 @@ enum FileFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -653,6 +656,7 @@ enum FileFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -661,6 +665,7 @@ enum FileFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -677,6 +682,7 @@ enum FileFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -692,6 +698,7 @@ enum FileFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -700,6 +707,7 @@ enum FileFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -708,6 +716,7 @@ enum FileFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type FileGroupConnection { @@ -838,6 +847,7 @@ enum DirectoryFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -853,6 +863,7 @@ enum DirectoryFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -861,6 +872,7 @@ enum DirectoryFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -877,6 +889,7 @@ enum DirectoryFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -892,6 +905,7 @@ enum DirectoryFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -900,6 +914,7 @@ enum DirectoryFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -908,6 +923,7 @@ enum DirectoryFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type DirectoryGroupConnection { @@ -1010,6 +1026,7 @@ enum SiteFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -1025,6 +1042,7 @@ enum SiteFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -1033,6 +1051,7 @@ enum SiteFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -1049,6 +1068,7 @@ enum SiteFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -1064,6 +1084,7 @@ enum SiteFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -1072,6 +1093,7 @@ enum SiteFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -1080,6 +1102,7 @@ enum SiteFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type SiteGroupConnection { @@ -1152,6 +1175,7 @@ enum SiteFunctionFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -1167,6 +1191,7 @@ enum SiteFunctionFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -1175,6 +1200,7 @@ enum SiteFunctionFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -1191,6 +1217,7 @@ enum SiteFunctionFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -1206,6 +1233,7 @@ enum SiteFunctionFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -1214,6 +1242,7 @@ enum SiteFunctionFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -1222,6 +1251,7 @@ enum SiteFunctionFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type SiteFunctionGroupConnection { @@ -1331,6 +1361,7 @@ enum SitePageFieldsEnum { pluginCreator___parent___internal___mediaType pluginCreator___parent___internal___owner pluginCreator___parent___internal___type + pluginCreator___parent___internal___contentFilePath pluginCreator___children pluginCreator___children___id pluginCreator___children___parent___id @@ -1346,6 +1377,7 @@ enum SitePageFieldsEnum { pluginCreator___children___internal___mediaType pluginCreator___children___internal___owner pluginCreator___children___internal___type + pluginCreator___children___internal___contentFilePath pluginCreator___internal___content pluginCreator___internal___contentDigest pluginCreator___internal___description @@ -1354,6 +1386,7 @@ enum SitePageFieldsEnum { pluginCreator___internal___mediaType pluginCreator___internal___owner pluginCreator___internal___type + pluginCreator___internal___contentFilePath id parent___id parent___parent___id @@ -1370,6 +1403,7 @@ enum SitePageFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -1385,6 +1419,7 @@ enum SitePageFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -1393,6 +1428,7 @@ enum SitePageFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -1409,6 +1445,7 @@ enum SitePageFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -1424,6 +1461,7 @@ enum SitePageFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -1432,6 +1470,7 @@ enum SitePageFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -1440,6 +1479,7 @@ enum SitePageFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type SitePageGroupConnection { @@ -1519,6 +1559,7 @@ enum SitePluginFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -1534,6 +1575,7 @@ enum SitePluginFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -1542,6 +1584,7 @@ enum SitePluginFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -1558,6 +1601,7 @@ enum SitePluginFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -1573,6 +1617,7 @@ enum SitePluginFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -1581,6 +1626,7 @@ enum SitePluginFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -1589,6 +1635,7 @@ enum SitePluginFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type SitePluginGroupConnection { @@ -1646,6 +1693,7 @@ enum SiteBuildMetadataFieldsEnum { parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -1661,6 +1709,7 @@ enum SiteBuildMetadataFieldsEnum { parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -1669,6 +1718,7 @@ enum SiteBuildMetadataFieldsEnum { parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -1685,6 +1735,7 @@ enum SiteBuildMetadataFieldsEnum { children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -1700,6 +1751,7 @@ enum SiteBuildMetadataFieldsEnum { children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -1708,6 +1760,7 @@ enum SiteBuildMetadataFieldsEnum { children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -1716,6 +1769,7 @@ enum SiteBuildMetadataFieldsEnum { internal___mediaType internal___owner internal___type + internal___contentFilePath } type SiteBuildMetadataGroupConnection { @@ -1890,6 +1944,7 @@ exports[`build and update individual types creates derived types 8`] = ` parent___parent___internal___mediaType parent___parent___internal___owner parent___parent___internal___type + parent___parent___internal___contentFilePath parent___children parent___children___id parent___children___parent___id @@ -1905,6 +1960,7 @@ exports[`build and update individual types creates derived types 8`] = ` parent___children___internal___mediaType parent___children___internal___owner parent___children___internal___type + parent___children___internal___contentFilePath parent___internal___content parent___internal___contentDigest parent___internal___description @@ -1913,6 +1969,7 @@ exports[`build and update individual types creates derived types 8`] = ` parent___internal___mediaType parent___internal___owner parent___internal___type + parent___internal___contentFilePath children children___id children___parent___id @@ -1929,6 +1986,7 @@ exports[`build and update individual types creates derived types 8`] = ` children___parent___internal___mediaType children___parent___internal___owner children___parent___internal___type + children___parent___internal___contentFilePath children___children children___children___id children___children___parent___id @@ -1944,6 +2002,7 @@ exports[`build and update individual types creates derived types 8`] = ` children___children___internal___mediaType children___children___internal___owner children___children___internal___type + children___children___internal___contentFilePath children___internal___content children___internal___contentDigest children___internal___description @@ -1952,6 +2011,7 @@ exports[`build and update individual types creates derived types 8`] = ` children___internal___mediaType children___internal___owner children___internal___type + children___internal___contentFilePath internal___content internal___contentDigest internal___description @@ -1960,6 +2020,7 @@ exports[`build and update individual types creates derived types 8`] = ` internal___mediaType internal___owner internal___type + internal___contentFilePath fields___field1 }" `; diff --git a/packages/gatsby/src/schema/types/node-interface.ts b/packages/gatsby/src/schema/types/node-interface.ts index 907656d497eb3..5769947f3381e 100644 --- a/packages/gatsby/src/schema/types/node-interface.ts +++ b/packages/gatsby/src/schema/types/node-interface.ts @@ -26,6 +26,7 @@ const getOrCreateNodeInterface = ( mediaType: `String`, owner: `String!`, type: `String!`, + contentFilePath: `String`, }) // TODO: Can be removed with graphql-compose 5.11 tc.getInputTypeComposer() diff --git a/packages/gatsby/src/utils/babel-loader-helpers.js b/packages/gatsby/src/utils/babel-loader-helpers.js index 3366c7a6f86ab..8cb7a5e32de08 100644 --- a/packages/gatsby/src/utils/babel-loader-helpers.js +++ b/packages/gatsby/src/utils/babel-loader-helpers.js @@ -71,11 +71,17 @@ const prepareOptions = ( ) { const apis = [`getServerData`, `config`] - if (resourceQuery === `?export=default`) { + if ( + resourceQuery.includes(`?export=default`) || + resourceQuery.includes(`&export=default`) + ) { apis.push(`Head`) } - if (resourceQuery === `?export=head`) { + if ( + resourceQuery.includes(`?export=head`) || + resourceQuery.includes(`&export=head`) + ) { apis.push(`default`) } diff --git a/packages/gatsby/src/utils/js-chunk-names.ts b/packages/gatsby/src/utils/js-chunk-names.ts index c5556a134acb8..b08337149fa97 100644 --- a/packages/gatsby/src/utils/js-chunk-names.ts +++ b/packages/gatsby/src/utils/js-chunk-names.ts @@ -3,7 +3,6 @@ import { kebabCase as _kebabCase } from "lodash" import { murmurhash as _murmurhash } from "babel-plugin-remove-graphql-queries/murmur" import path from "path" import { store } from "../redux" -import { getPathToContentComponent } from "gatsby-core-utils/parse-component-path" const kebabCase = memoize(_kebabCase) const pathRelative = memoize(path.relative) @@ -41,7 +40,6 @@ function replaceUnifiedRoutesKeys( const chunkNameCache = new Map() export function generateComponentChunkName(componentPath: string): string { - componentPath = getPathToContentComponent(componentPath) if (chunkNameCache.has(componentPath)) { return chunkNameCache.get(componentPath) } else { diff --git a/packages/gatsby/src/utils/webpack/plugins/__tests__/static-query-mapper.ts b/packages/gatsby/src/utils/webpack/plugins/__tests__/static-query-mapper.ts new file mode 100644 index 0000000000000..7d4a2c40354c3 --- /dev/null +++ b/packages/gatsby/src/utils/webpack/plugins/__tests__/static-query-mapper.ts @@ -0,0 +1,31 @@ +import { removeExportQueryParam } from "../static-query-mapper" + +const post = `/Users/dolores/project/post.tsx` + +describe(`removeExportQueryParam`, () => { + it(`should pass through path if it does not contain query param`, () => { + expect(removeExportQueryParam(post)).toEqual(post) + }) + it(`should pass through __contentFilePath`, () => { + const path = `${post}?__contentFilePath=/Users/dolores/project/file.mdx` + expect(removeExportQueryParam(path)).toEqual(path) + }) + it(`should remove ?export=default`, () => { + expect(removeExportQueryParam(`${post}?export=default`)).toEqual(post) + }) + it(`should remove ?export=head`, () => { + expect(removeExportQueryParam(`${post}?export=head`)).toEqual(post) + }) + it(`should remove export but keep __contentFilePath`, () => { + expect( + removeExportQueryParam( + `${post}?__contentFilePath=/Users/dolores/project/file.mdx&export=default` + ) + ).toEqual(`${post}?__contentFilePath=/Users/dolores/project/file.mdx`) + expect( + removeExportQueryParam( + `${post}?__contentFilePath=/Users/dolores/project/file.mdx&export=head` + ) + ).toEqual(`${post}?__contentFilePath=/Users/dolores/project/file.mdx`) + }) +}) diff --git a/packages/gatsby/src/utils/webpack/plugins/static-query-mapper.ts b/packages/gatsby/src/utils/webpack/plugins/static-query-mapper.ts index 654efdddb326d..b27d46ca4bc46 100644 --- a/packages/gatsby/src/utils/webpack/plugins/static-query-mapper.ts +++ b/packages/gatsby/src/utils/webpack/plugins/static-query-mapper.ts @@ -14,8 +14,27 @@ import type { type ChunkGroup = Compilation["chunkGroups"][0] type EntryPoint = Compilation["asyncEntrypoints"][0] -const removeExportQueryParam = (path: string | undefined): string | undefined => - path?.split(`?`)[0] +/** + * Remove the export query param from a path that can + * a) contain only the ?export= query param + * b) but also contain ?__contentFilePath&export= + */ +export const removeExportQueryParam = ( + path: string | undefined +): string | undefined => { + if (!path?.includes(`?`)) { + return path + } + const [filePath, queryParams] = path?.split(`?`) + const params = new URLSearchParams(queryParams) + params.delete(`export`) + + const paramsString = params.toString() + + return `${filePath}${ + paramsString ? `?${decodeURIComponent(paramsString)}` : `` + }` +} /** * Checks if a module matches a resourcePath