-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sitepage.context
no longer available in Gatsby v4 in generating sitemap.xml
#143
Comments
For those facing the same issue and wish to add back the context type as a quick workaround.
/**
* Workaround for missing sitePage.context:
* Used for generating sitemap with `gatsby-plugin-react-i18next` and `gatsby-plugin-sitemap` plugins
* https://www.gatsbyjs.com/docs/reference/release-notes/migrating-from-v3-to-v4/#field-sitepagecontext-is-no-longer-available-in-graphql-queries
*/
exports.createSchemaCustomization = ({ actions }) => {
const { createTypes } = actions
createTypes(`
type SitePage implements Node {
context: SitePageContext
}
type SitePageContext {
i18n: i18nContext
}
type i18nContext {
language: String,
languages: [String],
defaultLanguage: String,
originalPath: String
routed: Boolean
}
`)
} |
@wilsonvolker this is a great find, thanks! This query works now, but still the sitemap config gives back this error. Have you encountered it too?
|
Here's how I got the overall sitemap working again. I think the issue here is that people get stuck on the |
@bebbi thank you so much! I went through the exact issues that you described and your solution worked! I don't understand why the official doc is not up to date. I just installed with all the latest versions. |
I totally agree, the documentation should be updated with this new setup from @bebbi! Thank you. |
As documented in Here, it said we should query the
allSitePage
and filter it withcontext
schema.However, as mentioned by Gatsby official:
Field SitePage.context is no longer available in GraphQL queries
(source). If we still try to use the existing codes to generate sitemap through gatsby-plugin-sitemap, we will result in the following error:, and
Although the Gatsby official said we could create Sitepage.context manually as a workaround, it does not seem to be a good practice in the long term. Would there be any suggestion fix that satisfies the long-term goal? Thanks.
The text was updated successfully, but these errors were encountered: