It looks like there is no way to access nested context property values in page query variables. Is that correct?
Right now I'm duplicating the page context variable intl.language as language so I can use it as pageQuery variable.
_gatsby-node.js_
exports.onCreatePage = ({ page, actions: { createPage, deletePage } }) => {
if (!page.context.intl || page.context.language) {
return;
}
deletePage(page);
createPage({
...page,
context: {
...page.context,
language: page.context.intl.language },
});
};
_src/pages/index.jsx_
export const query = graphql`
query MyQuery($language: String!) {
# …
}
`
Ideally I could access nested context variables by default.
_gatsby-node.js_
-exports.onCreatePage = ({ page, actions: { createPage, deletePage } }) => {
- if (!page.context.intl || page.context.language) {
- return;
- }
- deletePage(page);
- createPage({
- ...page,
- context: {
- ...page.context,
- language: page.context.intl.language },
- });
-};
_src/pages/index.jsx_
export const query = graphql`
- query MyQuery($language: String!) {
+ query MyQuery($intl__language: String!) {
# …
}
`
If this is an acceptable addition I'd love to PR.
Hiya!
This issue has gone quiet. Spooky quiet. 👻
We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 💪💜
Hey again!
It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks again for being part of the Gatsby community!
This is not a great experience. I would PR fixes and improvements if I got feedback.
But as it is now I'm not inclined to open another issue again. You're losing potential contributors this way.
Hmmm, shame this never got any attention. However, I would like to thank you for sharing your solution nevertheless! Helped me out today
Is it still the case that this isn't possible? Running into the same thing.
Having same issue
Same here!
Most helpful comment
Hmmm, shame this never got any attention. However, I would like to thank you for sharing your solution nevertheless! Helped me out today