Skip to content

Commit

Permalink
fix(plugin-sitemap): missing data in query results (#22843)
Browse files Browse the repository at this point in the history
* fix: #22703 missing data in serialize funciton

* fix: revert a couple changes for url resolution to not change and get whole query

* refactor: move otherData spread to top so site is overritten by propper url if needed

* test: add test to confirm non standard data is passed
  • Loading branch information
moonmeister authored Apr 11, 2020
1 parent eacffd9 commit cff1d7f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/gatsby-plugin-sitemap/src/__tests__/internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ describe(`results using non default alternatives`, () => {
},
],
},
otherData: {
nodes: [
{
name: `test`,
},
{
name: `test 2`,
},
],
},
},
}
}
Expand All @@ -161,5 +171,6 @@ describe(`results using non default alternatives`, () => {
const queryRecords = filterQuery(results, [], ``, customSiteResolver)

expect(queryRecords.site.siteMetadata.siteUrl).toEqual(customUrl)
expect(queryRecords).toHaveProperty(`otherData`)
})
})
5 changes: 4 additions & 1 deletion packages/gatsby-plugin-sitemap/src/internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export function filterQuery(
throw new Error(errors.join(`, `))
}

let { allPages, originalType } = getNodes(data.allSitePage)
const { allSitePage, ...otherData } = data

let { allPages, originalType } = getNodes(allSitePage)

// Removing excluded paths
allPages = allPages.filter(
Expand Down Expand Up @@ -53,6 +55,7 @@ export function filterQuery(
siteUrl = withoutTrailingSlash(siteUrl)

return {
...otherData,
allSitePage: {
[originalType]:
originalType === `nodes`
Expand Down

0 comments on commit cff1d7f

Please sign in to comment.