{"action":"created","issue":{"url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/7747","repository_url":"https://api.github.com/repos/gatsbyjs/gatsby","labels_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/7747/labels{/name}","comments_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/7747/comments","events_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/7747/events","html_url":"https://github.com/gatsbyjs/gatsby/issues/7747","id":355579452,"node_id":"MDU6SXNzdWUzNTU1Nzk0NTI=","number":7747,"title":"StaticQuery silently fails when used inside wrapRootElement and wrapPageElement","user":{"login":"sbugert","id":2883939,"node_id":"MDQ6VXNlcjI4ODM5Mzk=","avatar_url":"https://avatars1.githubusercontent.com/u/2883939?v=4","gravatar_id":"","url":"https://api.github.com/users/sbugert","html_url":"https://github.com/sbugert","followers_url":"https://api.github.com/users/sbugert/followers","following_url":"https://api.github.com/users/sbugert/following{/other_user}","gists_url":"https://api.github.com/users/sbugert/gists{/gist_id}","starred_url":"https://api.github.com/users/sbugert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbugert/subscriptions","organizations_url":"https://api.github.com/users/sbugert/orgs","repos_url":"https://api.github.com/users/sbugert/repos","events_url":"https://api.github.com/users/sbugert/events{/privacy}","received_events_url":"https://api.github.com/users/sbugert/received_events","type":"User","site_admin":false},"labels":[{"id":1038050719,"node_id":"MDU6TGFiZWwxMDM4MDUwNzE5","url":"https://api.github.com/repos/gatsbyjs/gatsby/labels/status:%20inkteam%20to%20review","name":"status: inkteam to review","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-08-30T13:13:25Z","updated_at":"2018-11-20T15:29:42Z","closed_at":null,"author_association":"NONE","body":"<!--\r\n  To make it easier for us to help you — please follow the suggested format below.\r\n\r\n  Useful Links:\r\n  - Documentation: https://www.gatsbyjs.org/docs/\r\n  - How to File an Issue: https://www.gatsbyjs.org/docs/how-to-file-an-issue/\r\n\r\n  Before opening a new issue, please search existing issues https://github.com/gatsbyjs/gatsby/issues\r\n-->\r\n\r\n## Description\r\n\r\nUsing a `StaticQuery` in a a component inside `wrapRootElement` or `wrapPageElement` results in _Loading (StaticQuery)_ both for `gatsby-node.js` and `gatsby-ssr.js`.\r\n\r\n### Steps to reproduce\r\n\r\nUsing this wrapRootElement implementation the issue appears:\r\n```js\r\nimport React from 'react'\r\nimport { graphql, StaticQuery } from 'gatsby'\r\n\r\nexport const wrapRootElement = ({ element }) => (\r\n  <StaticQuery\r\n    query={graphql`\r\n      query {\r\n        site {\r\n          siteMetadata {\r\n            title\r\n          }\r\n        }\r\n      }\r\n    `}\r\n    render={data => element}\r\n  />\r\n)\r\n```\r\n\r\nWhen using this code, the context is empty which seems to be the reason.\r\n```js\r\nimport React from 'react'\r\nimport { StaticQueryContext } from 'gatsby'\r\n\r\nexport const wrapRootElement = ({ element }) => (\r\n  <StaticQueryContext.Consumer>\r\n    {staticQueryData => {\r\n      console.log(staticQueryData)\r\n      return element\r\n    }}\r\n  </StaticQueryContext.Consumer>\r\n)\r\n\r\n```\r\n\r\n### Expected result\r\n\r\nThe context should be set for the `wrapRootElement` and `wrapPageElement` APIs or if this is intended, there should be a warning in StaticQuery if no context is available.\r\n\r\n### Actual result\r\n\r\nIt fails silently and appears to be loading forever.\r\n\r\n### Environment\r\n\r\n```\r\n  System:\r\n    OS: Linux 4.4 Ubuntu 16.04.5 LTS (Xenial Xerus)\r\n    CPU: x64 Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz\r\n    Shell: 4.3.48 - /bin/bash\r\n  Binaries:\r\n    Node: 10.9.0 - ~/opt/node/latest/bin/node\r\n    Yarn: 1.9.4 - ~/opt/node/latest/bin/yarn\r\n    npm: 6.4.1 - ~/opt/node/latest/bin/npm\r\n  Browsers:\r\n    Chrome: 68.0.3440.106\r\n    Firefox: 61.0.1\r\n  npmPackages:\r\n    gatsby: next => 2.0.0-rc.4 \r\n    gatsby-plugin-manifest: next => 2.0.2-rc.1 \r\n    gatsby-plugin-offline: next => 2.0.0-rc.1 \r\n    gatsby-plugin-react-helmet: next => 3.0.0-rc.1 \r\n  npmGlobalPackages:\r\n    gatsby-cli: 1.1.58\r\n```\r\n\r\n### File contents (if changed)\r\n\r\n`gatsby-config.js`: N/A <!-- Please use a code block or just leave it as is if wasn't changed -->\r\n`package.json`: N/A <!-- Please use a code block or just leave it as is if wasn't changed -->\r\n`gatsby-node.js`: see above\r\n`gatsby-browser.js`: see above\r\n`gatsby-ssr.js`: N/A <!-- Please use a code block or just leave it as is if wasn't changed -->\r\n\r\n\r\n\r\nIf given some general directions, I would be happy to contribute and make a PR for this issue."},"comment":{"url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/comments/440314071","html_url":"https://github.com/gatsbyjs/gatsby/issues/7747#issuecomment-440314071","issue_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/7747","id":440314071,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDMxNDA3MQ==","user":{"login":"coxom","id":35224636,"node_id":"MDQ6VXNlcjM1MjI0NjM2","avatar_url":"https://avatars3.githubusercontent.com/u/35224636?v=4","gravatar_id":"","url":"https://api.github.com/users/coxom","html_url":"https://github.com/coxom","followers_url":"https://api.github.com/users/coxom/followers","following_url":"https://api.github.com/users/coxom/following{/other_user}","gists_url":"https://api.github.com/users/coxom/gists{/gist_id}","starred_url":"https://api.github.com/users/coxom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coxom/subscriptions","organizations_url":"https://api.github.com/users/coxom/orgs","repos_url":"https://api.github.com/users/coxom/repos","events_url":"https://api.github.com/users/coxom/events{/privacy}","received_events_url":"https://api.github.com/users/coxom/received_events","type":"User","site_admin":false},"created_at":"2018-11-20T15:29:42Z","updated_at":"2018-11-20T15:29:42Z","author_association":"NONE","body":"> I ve got the same problem after many research it's appear that you need to put the file where is located your staticquery in the folder ./src else you will get \"Loading (StaticQuery)\"\r\n\r\nI seem to have run into this issue also. But my code is already inside the src. I use other StaticQueries without problem. Just one that is building a cache and used in wrapRootElement causes problems."}}
{"actor":{"display_login":"coxom"}}