Skip to content

Commit

Permalink
Small bug fixes (#835)
Browse files Browse the repository at this point in the history
* Update to contentDigest

* Wait for all queries to finish

* Actually save new connection dependencies

* This was leftover code which started causing trouble with caching
  • Loading branch information
KyleAMathews committed Apr 21, 2017
1 parent 8b87236 commit 777ca60
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
4 changes: 2 additions & 2 deletions packages/gatsby-typegen-remark-copy-linked-files/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ module.exports = ({ files, markdownNode, markdownAST, getNode }) => {
const newPath = path.join(
process.cwd(),
`public`,
`${linkNode.hash}.${linkNode.extension}`
`${linkNode.contentDigest}.${linkNode.extension}`
)
const relativePath = path.join(
`/${linkNode.hash}.${linkNode.extension}`
`/${linkNode.contentDigest}.${linkNode.extension}`
)
link.url = `${relativePath}`
if (!fsExtra.existsSync(newPath)) {
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby-typegen-remark/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ exports.extendNodeType = (
}

pluginsCacheStr = pluginOptions.plugins.map(p => p.name).join("")
console.log("pluginsCacheStr", pluginsCacheStr)

return new Promise((resolve, reject) => {
const files = allNodes.filter(n => n.type === `File`)
Expand Down
18 changes: 10 additions & 8 deletions packages/gatsby/lib/query-runner/page-query-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ checkpointsPromise({
// Find paths without data dependencies and run them (just in case?)
const paths = findPathsWithoutDataDependencies()
// Run these pages
paths.forEach(path => {
const page = state.pages.find(p => p.path === path)
const component = state.pageComponents[page.component]
queryRunner(page, component)
Promise.all(
paths.map(path => {
const page = state.pages.find(p => p.path === path)
const component = state.pageComponents[page.component]
return queryRunner(page, component)
})
).then(() => {
// Tell everyone who cares that we're done.
callbacks.forEach(cb => cb())
})

// Tell everyone who cares that we're done.
callbacks.forEach(cb => cb())
})
})

Expand Down Expand Up @@ -96,7 +98,7 @@ const findAndRunQueriesForDirtyPaths = actions => {
})

if (dirtyPaths.length > 0) {
console.log(`all pages invalidated by node change`, dirtyPaths)
console.log(`all pages invalidated by node change`, _.uniq(dirtyPaths))

// Run these pages
return Promise.all(
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/lib/redux/actions/add-page-dependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exports.addPageDependency = ({ path, nodeId, connection }) => {
}
if (
connection &&
_.has(state, `pageDataDependencies.connections.${connection}`)
_.includes(state.pageDataDependencies.connections, connection)
) {
connectionDependencyExists = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,20 @@ describe(`add page data dependency`, () => {
connection: `Markdown.Remark`,
},
}
const action2 = {
type: `ADD_PAGE_DEPENDENCY`,
payload: {
path: `/hi2/`,
connection: `Markdown.Remark`,
},
}

expect(reducer(undefined, action)).toEqual({
let state = reducer(undefined, action)
state = reducer(state, action2)

expect(state).toEqual({
connections: {
"Markdown.Remark": ["/hi/"],
"Markdown.Remark": ["/hi/", "/hi2/"],
},
nodes: {},
})
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby/lib/schema/build-node-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ module.exports = async () =>
name: _.camelCase(`${typeName} field`),
type: nodeType.nodeObjectType,
resolve: (node, a, context, { fieldName }) => {
const fieldSelector = `${node.___path}.${fieldName}`
let fieldValue = node[fieldName]
const sourceFileNode = _.find(
getNodes(),
Expand Down
9 changes: 0 additions & 9 deletions packages/gatsby/lib/schema/infer-graphql-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,6 @@ const inferObjectStructureFromNodes = (exports.inferObjectStructureFromNodes = (
})
})

// Add the "path" to each subnode as we'll need this later when resolving
// mapped fields to types in GraphQL land. We do that here (after creating
// field examples) so our special field is not added to the GraphQL type.
if (selector) {
nodes.forEach(node => {
_.set(node, `${selector}.___path`, `${type}.${selector}`)
})
}

// Remove fields common to the top-level of all nodes. We add these
// elsewhere so don't need to infer there type.
if (!selector) {
Expand Down

0 comments on commit 777ca60

Please sign in to comment.