Gatsby: Don't print GraphQL query in the non-page component will not be run error in unused templates

Created on 4 Jan 2020  路  13Comments  路  Source: gatsbyjs/gatsby

I can not find out how to get rid of these warnings in console log during build time.

warn The GraphQL query in the non-page component "...some path..." will not be run.

Cause of warning is unused template and not GraphQL in non-page component at the first place.

Sice I use headless CMS for sourcing Gatsby I can not rely that CMS user creates always all page types for all Gatsby's templates. Thus it is common for me that some templates remain unused. I was looking for some "if" condition to prevent this warning but unsuccessfully. So currently my log is filling with this misleading information.

It would be nice to have a way how to say that unused templates can be intentional and do not printing warnings.

help wanted themes

Most helpful comment

Steps to reproduce

I'm shadowing queries of a theme.

Expected result

I should not get warnings. The queries should execute for page components.

Actual result

success extract queries from components - 0.359s
warn The GraphQL query in the non-page component "/Users/dcaldas/dev/goodguydaniel.com/node_modules/@lekoarts/gatsby-theme-minimal-blog-core/src/templates/homepage-query.tsx" will not be run.
warn The GraphQL query in the non-page component "/Users/dcaldas/dev/goodguydaniel.com/node_modules/@lekoarts/gatsby-theme-minimal-blog-core/src/templates/post-query.tsx" will not be run.
Exported queries are only executed for Page components. It's possible you're
trying to create pages in your gatsby-node.js and that's failing for some
reason.

Environment

  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 12.10.0 - ~/.nvm/versions/node/v12.10.0/bin/node
    Yarn: 1.21.1 - ~/.yarn/bin/yarn
    npm: 6.10.3 - ~/.nvm/versions/node/v12.10.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 83.0.4103.61
    Edge: 83.0.478.44
    Firefox: 76.0.1
    Safari: 13.1
  npmPackages:
    gatsby: ^2.20.36 => 2.22.10
    gatsby-plugin-anchor-links: ^1.1.1 => 1.1.1
    gatsby-plugin-google-analytics: ^2.1.4 => 2.3.2
    gatsby-plugin-manifest: ^2.2.3 => 2.4.9
    gatsby-plugin-offline: ^2.2.4 => 2.2.10
    gatsby-plugin-sitemap: ^2.2.19 => 2.4.3
    gatsby-remark-autolink-headers: ^2.3.3 => 2.3.3
    gatsby-transformer-remark: ^2.8.13 => 2.8.13
  npmGlobalPackages:
    gatsby-cli: 2.12.34

All 13 comments

It would be nice to have a way how to say that unused templates can be intentional and do not printing warnings.

Great point.

Perhaps we need a /* eslint-disable */ style method to disable Gatsby warnings for cases like these since there isn't a way to know which templates are used.

Or even better, maybe we need conditionally print these only if the template is used (cc @pieh tangentially related to our idea of AOT validation of queries but printing only if used)

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鈥檚 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/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

Hey again!

It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.
Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 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! 馃挭馃挏

Or for shadowed templates.

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鈥檚 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/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

This is still a problem.

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鈥檚 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/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

Hey again!

It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.
Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 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 still a problem.

Steps to reproduce

I'm shadowing queries of a theme.

Expected result

I should not get warnings. The queries should execute for page components.

Actual result

success extract queries from components - 0.359s
warn The GraphQL query in the non-page component "/Users/dcaldas/dev/goodguydaniel.com/node_modules/@lekoarts/gatsby-theme-minimal-blog-core/src/templates/homepage-query.tsx" will not be run.
warn The GraphQL query in the non-page component "/Users/dcaldas/dev/goodguydaniel.com/node_modules/@lekoarts/gatsby-theme-minimal-blog-core/src/templates/post-query.tsx" will not be run.
Exported queries are only executed for Page components. It's possible you're
trying to create pages in your gatsby-node.js and that's failing for some
reason.

Environment

  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 12.10.0 - ~/.nvm/versions/node/v12.10.0/bin/node
    Yarn: 1.21.1 - ~/.yarn/bin/yarn
    npm: 6.10.3 - ~/.nvm/versions/node/v12.10.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 83.0.4103.61
    Edge: 83.0.478.44
    Firefox: 76.0.1
    Safari: 13.1
  npmPackages:
    gatsby: ^2.20.36 => 2.22.10
    gatsby-plugin-anchor-links: ^1.1.1 => 1.1.1
    gatsby-plugin-google-analytics: ^2.1.4 => 2.3.2
    gatsby-plugin-manifest: ^2.2.3 => 2.4.9
    gatsby-plugin-offline: ^2.2.4 => 2.2.10
    gatsby-plugin-sitemap: ^2.2.19 => 2.4.3
    gatsby-remark-autolink-headers: ^2.3.3 => 2.3.3
    gatsby-transformer-remark: ^2.8.13 => 2.8.13
  npmGlobalPackages:
    gatsby-cli: 2.12.34

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鈥檚 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/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

This is still a problem.

I'll close this in favor of https://github.com/gatsbyjs/gatsby/issues/23729 as this has a reproduction and clearer description while being the same issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theduke picture theduke  路  3Comments

dustinhorton picture dustinhorton  路  3Comments

kalinchernev picture kalinchernev  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments

3CordGuy picture 3CordGuy  路  3Comments