Skip to content

Commit 3095506

Browse files
authored
fix(gatsby,gatsby-plugin-page-creator): Materialize nodes in gatsbyPath (#37111)
1 parent 5580c73 commit 3095506

File tree

12 files changed

+617
-482
lines changed

12 files changed

+617
-482
lines changed

e2e-tests/development-runtime/cypress/integration/unified-routing/collection-routing.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,11 @@ describe(`collection-routing`, () => {
143143
assert404(`updated-node`)
144144
})
145145
})
146+
147+
it(`gatsbyPath should support materialized field values`, () => {
148+
cy.visit(`/collection-routing/gatsby-path-materialized-linked-name/gatsby-path-materialized-parent-name`).waitForRouteChange()
149+
150+
cy.findByTestId(`gatsby-path-materialized`)
151+
cy.should(`have.text`, `/collection-routing/gatsby-path-materialized-linked-name/gatsby-path-materialized-parent-name/`)
152+
})
146153
})

e2e-tests/development-runtime/gatsby-node.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ exports.createSchemaCustomization = ({ actions, schema, store }) => {
3030
slug: String!
3131
content: String!
3232
}
33+
34+
type GatsbyPathMaterializedParent implements Node {
35+
childType: GatsbyPathMaterializedLinked @link(by: "name")
36+
}
37+
38+
type GatsbyPathMaterializedLinked implements Node {
39+
name: String!
40+
}
3341
`)
3442
}
3543

@@ -91,6 +99,29 @@ exports.sourceNodes = ({ actions, createNodeId, createContentDigest }) => {
9199
contentDigest: createContentDigest(`Some words`),
92100
},
93101
})
102+
103+
actions.createNode({
104+
id: createNodeId(`gatsby-path-materialized-parent`),
105+
name: `gatsby-path-materialized Parent Name`,
106+
childType: `gatsby-path-materialized Linked Name`,
107+
parent: null,
108+
children: [],
109+
internal: {
110+
type: `GatsbyPathMaterializedParent`,
111+
contentDigest: createContentDigest(`Some words`),
112+
},
113+
})
114+
115+
actions.createNode({
116+
id: createNodeId(`gatsby-path-materialized-linked`),
117+
name: `gatsby-path-materialized Linked Name`,
118+
parent: null,
119+
children: [],
120+
internal: {
121+
type: `GatsbyPathMaterializedLinked`,
122+
contentDigest: createContentDigest(`Some words`),
123+
},
124+
})
94125
}
95126

96127
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as React from "react"
2+
import { Link, graphql } from "gatsby"
3+
import Layout from "../../../components/layout"
4+
5+
const MaterializedPage = (props) => (
6+
<Layout>
7+
<p data-testid="gatsby-path-materialized">{props.data.gatsbyPathMaterializedParent.gatsbyPath}</p>
8+
<Link to="/">Back to home</Link>
9+
</Layout>
10+
)
11+
12+
export default MaterializedPage
13+
14+
export const query = graphql`
15+
query {
16+
gatsbyPathMaterializedParent {
17+
name
18+
gatsbyPath(
19+
filePath: "/collection-routing/{GatsbyPathMaterializedParent.childType__name}/{GatsbyPathMaterializedParent.name}"
20+
)
21+
}
22+
}
23+
`

0 commit comments

Comments
 (0)