After reinstalling all npm modules without yarn.lock
See original GitHub issueDescription
I reinstalled all npm modules without yarn.lock and got this error. In the demo-repo I saved yarn.lock that breaks build. Also I added yarn.lock.nice with which build works fine.
gatsby build
returns the following error:
ERROR #85910 GRAPHQL
Multiple "root" queries found: "yQuery" and "BlogPostBySlug".
Only the first ("BlogPostBySlug") will be registered.
Instead of:
1 | query BlogPostBySlug {
2 | allMarkdownRemark {
3 | #...
4 | }
5 | }
6 |
7 | query yQuery {
8 | site {
9 | #...
10 | }
11 | }
Do:
1 | query yQueryAndBlogPostBySlug {
2 | allMarkdownRemark {
3 | #...
4 | }
5 | site {
6 | #...
7 | }
8 | }
This can happen when you use two page/static queries in one file. Please combine those into one query.
If you're defining multiple components (each with a static query) in one file, you'll need to move each component to its own file.
File: src/templates/blog-post.tsx
Steps to reproduce
I’ve prepared demo repo
After clonning do the following steps:
yarn install
gatsby build
Expected result
build should complete
Actual result
build failed
Environment
System: OS: Linux 4.15 Ubuntu 16.04.6 LTS (Xenial Xerus) CPU: (8) x64 AMD FX™-8350 Eight-Core Processor Shell: 4.3.48 - /bin/bash Binaries: Node: 10.14.1 - /usr/local/bin/node Yarn: 1.17.3 - /usr/bin/yarn npm: 6.4.1 - /usr/local/bin/npm Languages: Python: 2.7.12 - /usr/bin/python Browsers: Chrome: 76.0.3809.87 npmPackages: gatsby: ^2.3.16 => 2.18.17 gatsby-image: ^2.0.37 => 2.2.37 gatsby-plugin-feed: ^2.1.0 => 2.3.25 gatsby-plugin-google-analytics: ^2.0.18 => 2.1.31 gatsby-plugin-lodash: ^3.0.5 => 3.1.18 gatsby-plugin-mailchimp: ^5.1.0 => 5.1.2 gatsby-plugin-manifest: ^2.0.28 => 2.2.34 gatsby-plugin-netlify-cache: ^1.2.0 => 1.2.0 gatsby-plugin-netlify-cms: ^4.1.33 => 4.1.33 gatsby-plugin-offline: ^2.0.25 => 2.2.10 gatsby-plugin-prefetch-google-fonts: ^1.4.2 => 1.4.3 gatsby-plugin-react-helmet: ^3.0.12 => 3.1.18 gatsby-plugin-sharp: ^2.0.32 => 2.3.10 gatsby-plugin-styled-components: ^3.0.7 => 3.1.16 gatsby-plugin-typescript: ^2.0.12 => 2.1.23 gatsby-remark-copy-linked-files: ^2.0.11 => 2.1.33 gatsby-remark-images: ^2.0.6 => 2.0.6 gatsby-remark-katex: ^3.0.4 => 3.1.20 gatsby-remark-mermaid: ^1.0.0 => 1.2.0 gatsby-remark-prismjs: ^3.2.8 => 3.3.28 gatsby-remark-relative-images: ^0.2.3 => 0.2.3 gatsby-remark-responsive-iframe: ^2.1.1 => 2.2.30 gatsby-remark-smartypants: ^2.0.9 => 2.1.19 gatsby-source-filesystem: ^2.0.29 => 2.1.43 gatsby-source-instagram: ^0.5.0 => 0.5.1 gatsby-transformer-remark: ^2.3.8 => 2.6.45 gatsby-transformer-sharp: ^2.1.17 => 2.3.9 npmGlobalPackages: gatsby-cli: 2.7.53
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
I’m getting the error in the default blog starter template: Multiple “root” queries found: “BlogPostBySlug” and “BlogPostBySlug” There is only one root query on my template file templates/blog-post.js. When it’s removed, the homepage loads, but none of the posts work. Is this an issue with the version of gatsbly CLI?
We reworked query extraction recently. The new extractor discovered this error when the old one (erroneously) skipped it.