Skip to content

Commit

Permalink
fix(gatsby,gatsby-plugin-page-creator): Materialize nodes in gatsbyPa…
Browse files Browse the repository at this point in the history
…th (#37111)
  • Loading branch information
LekoArts authored Dec 6, 2022
1 parent 5580c73 commit 3095506
Show file tree
Hide file tree
Showing 12 changed files with 617 additions and 482 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,11 @@ describe(`collection-routing`, () => {
assert404(`updated-node`)
})
})

it(`gatsbyPath should support materialized field values`, () => {
cy.visit(`/collection-routing/gatsby-path-materialized-linked-name/gatsby-path-materialized-parent-name`).waitForRouteChange()

cy.findByTestId(`gatsby-path-materialized`)
cy.should(`have.text`, `/collection-routing/gatsby-path-materialized-linked-name/gatsby-path-materialized-parent-name/`)
})
})
31 changes: 31 additions & 0 deletions e2e-tests/development-runtime/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ exports.createSchemaCustomization = ({ actions, schema, store }) => {
slug: String!
content: String!
}
type GatsbyPathMaterializedParent implements Node {
childType: GatsbyPathMaterializedLinked @link(by: "name")
}
type GatsbyPathMaterializedLinked implements Node {
name: String!
}
`)
}

Expand Down Expand Up @@ -91,6 +99,29 @@ exports.sourceNodes = ({ actions, createNodeId, createContentDigest }) => {
contentDigest: createContentDigest(`Some words`),
},
})

actions.createNode({
id: createNodeId(`gatsby-path-materialized-parent`),
name: `gatsby-path-materialized Parent Name`,
childType: `gatsby-path-materialized Linked Name`,
parent: null,
children: [],
internal: {
type: `GatsbyPathMaterializedParent`,
contentDigest: createContentDigest(`Some words`),
},
})

actions.createNode({
id: createNodeId(`gatsby-path-materialized-linked`),
name: `gatsby-path-materialized Linked Name`,
parent: null,
children: [],
internal: {
type: `GatsbyPathMaterializedLinked`,
contentDigest: createContentDigest(`Some words`),
},
})
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from "react"
import { Link, graphql } from "gatsby"
import Layout from "../../../components/layout"

const MaterializedPage = (props) => (
<Layout>
<p data-testid="gatsby-path-materialized">{props.data.gatsbyPathMaterializedParent.gatsbyPath}</p>
<Link to="/">Back to home</Link>
</Layout>
)

export default MaterializedPage

export const query = graphql`
query {
gatsbyPathMaterializedParent {
name
gatsbyPath(
filePath: "/collection-routing/{GatsbyPathMaterializedParent.childType__name}/{GatsbyPathMaterializedParent.name}"
)
}
}
`
Loading

0 comments on commit 3095506

Please sign in to comment.