gatsby-plugin-react-i18next
gatsby-plugin-react-i18next copied to clipboard
Alternative for query in every page
Is there a way to migrate from 0.2.x to 1.x without having to add the same query to every single page just to get the same behaviour as before? Would be great not to have this code repeated dozens of times in the codebase.
This is something we all need I guess. 🙌
+1, this made migrating to the new plugin much more of a pain and makes the queries on many of our sub pages much less clean.
+1, and I get that error and I don't know why:

👋 Bit of a time has passed but I found using a graphql fragment made this a bit cleaner:
Include this in a js
file somewhere in the src/
directory (like /src/fragments/locales.js
):
import { graphql } from "gatsby"
// This should be your allLocale query that you want to include everywhere
export const query = graphql`
fragment Locales on Query {
locales: allLocale {
edges {
node {
ns
data
language
}
}
}
}
`
and then on your page queries you can do:
query {
...Locales
}