gatsby: Queries from unused themes cause "gatsby develop" to fail

Description

Queries from themes that aren’t being used cause an app to fail. It’s sort of an abrupt experience to have installing a package make your app crash when it isn’t configured. I’m not sure if we should check to make sure a theme is being used or if we should error in a more friendly way that says to configure the theme or use it.

Steps to reproduce

gatsby new my-themed-blog https://github.com/gatsbyjs/gatsby-starter-blog-theme
cd my-theme-blog
yarn add gatsby-theme-documentation
yarn start

Expected result

The blog theme runs unaffected by the docs theme which isn’t configured.

Actual result

We receive an error that crashes the app:

 ERROR #85907  GRAPHQL

There was an error in your GraphQL query:

- Unknown field 'docs' on type 'Query'.

File: node_modules/gatsby-theme-documentation/src/templates/doc.js

image

Related

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (13 by maintainers)

Most upvoted comments

Yeah we don’t run the queries, is the validation step. Perhaps we could store the errors for queries and only show them if we know the query is used in a component.

@pvdz I’m running into an issue related to this which is less breaking but possibly more common in theme development. If a theme developer allows page queries to be replaced through shadowing or other means, the original query will still show the “GraphQL query in the non-page component” warning despite the theme being used as intended. Ultimately, solving this variant of the issue is mostly to assuage the worries of developers consuming themes who may incorrectly think something is wrong, so while it expands the pool of cases it only does so with cosmetic issues. I think @KyleAMathews proposal would fix this as well.

@KyleAMathews I am being hit by this sort of error from disabled components. I would think your proposed solution would resolve my problem (whereas I suspect the linked PR would not)

Anyone know how common this case is? Do people often have unused themes in their build? Or mostly when initially setting up? Wondering about the impact surface of this problem.