Docz: Gastby Error: RelayParser - Duplicated documents: - DefaultSEOQuery

Created on 4 Jul 2019  ·  10Comments  ·  Source: doczjs/docz

Bug Report

Describe the bug
Gatsby build is broken. I followed the instructions of https://www.docz.site/docs/gatsby-theme#how-to-use

A clear and concise description of what the bug is.

When i lunch my gatsby develop.

To Reproduce

  1. Go to https://github.com/sutter/hello-gatsby/tree/feature/add-documentation'
  2. clone the repo read the readme for install dev dependecies
➜  hello-gatsby git:(feature/add-documentation) gatsby develop
Configuring yargs through package.json is deprecated and will be removed in the
success open and validate gatsby-configs - 2.034 s
success load plugins - 0.970 s
Configuring yargs through package.json is deprecated and will be removed in the
success onPreInit - 0.312 s
success initialize cache - 0.006 s
success copy gatsby files - 0.066 s
success onPreBootstrap - 0.009 s
Configuring yargs through package.json is deprecated and will be removed in the
success source and transform nodes - 0.532 s
success building schema - 0.287 s
Configuring yargs through package.json is deprecated and will be removed in the
success createPages - 0.309 s
success createPagesStatefully - 0.036 s
success onPreExtractQueries - 0.002 s
success update schema - 0.041 s

 ERROR 

There was a problem parsing "/Users/laurentsutterlity/Works/hello-gatsby/node_modules/gatsby-theme-docz/templates/Layout.tpl.js"; any GraphQL fragments or queries in this file were not processed.
This may indicate a syntax error in the code, or it may be a file type that Gatsby does not know how to parse.


 ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Error: RelayParser: Encountered duplicate defintitions for one or more documents: each document must have a unique name. Duplicated documents:
- DefaultSEOQuery

success extract queries from components - 8.357 s
success write out requires - 0.008 s
success write out redirect data - 0.002 s
success Build manifest and related icons - 0.137 s
success onPostBootstrap - 0.144 s
⠀
info bootstrap finished - 17.704 s
⠀
success run static queries - 0.002 s
success run page queries - 0.026 s — 7/7 292.91 queries/second
 DONE  Compiled successfully in 6477ms                                    09:12:11
⠀
You can now view hello-gatsby in the browser.
⠀
  http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  http://localhost:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use npm run build

Environment

  • OS: [10.14.5]
  • Node version: [v10.15.3]
  • Yarn version: [1.15.2]
bug stale v1

Most helpful comment

If anyone is using v2, just make sure your gatsby is up to date and you should be fine, now for anyone that is for whatever reason stuck on v1 (like me) you can solve the problem locally by altering a file from the docz gatsby theme In your node_modules the main downside with that is anytime you add or update your dependencies it will overwrite the fix, but for me just replacing the file as a part of my build has allowed me to keep it totally automated.

The main issue is the file node_modules/gatsby-theme-docs/templates/Seo.js.tpl it exports a query and because its intended to be a template to generate another file, but it’s still processed by gatsby , we end up with its query name duplicated in the schema, ie error. So to fix it, you just need to remove the name from the query, since query names are only required in graphql when using variables, so this query doesn’t need a name, so in that file just change

query DefaultSeoQuery {

Into

query {

All 10 comments

This is a bug related to the new version of Gatsby, I think that they're working to fix this.
cc @pieh

similar issue here

Hitting the same issue as well, Do you know if there is a previous version of Gatsby that could still work or is it a dependency mess to even consider an older version?

I'm having similar issue after installing Docz theme.

EDIT: Actually, I'm having the exact same issue.
Are there any workarounds?

Same here, after installing Docz Theme.

EDIT: do we have news about this issue?

I'm encountering this problem as well after trying to migrate to v2. And why does it have the v1 tag if it's related to Gatsby ?

Facing this issue on v2.0.0-rc.31 😬

If anyone is using v2, just make sure your gatsby is up to date and you should be fine, now for anyone that is for whatever reason stuck on v1 (like me) you can solve the problem locally by altering a file from the docz gatsby theme In your node_modules the main downside with that is anytime you add or update your dependencies it will overwrite the fix, but for me just replacing the file as a part of my build has allowed me to keep it totally automated.

The main issue is the file node_modules/gatsby-theme-docs/templates/Seo.js.tpl it exports a query and because its intended to be a template to generate another file, but it’s still processed by gatsby , we end up with its query name duplicated in the schema, ie error. So to fix it, you just need to remove the name from the query, since query names are only required in graphql when using variables, so this query doesn’t need a name, so in that file just change

query DefaultSeoQuery {

Into

query {

Thanks @jstacoder for the solution 👍 !

Make sure to check out patch-package if you use @jstacoder's solution to consistently alter your node_modules as part of your build step.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bichotll picture bichotll  ·  3Comments

wldcordeiro picture wldcordeiro  ·  3Comments

w0wka91 picture w0wka91  ·  3Comments

mquandalle picture mquandalle  ·  3Comments

ssylvia picture ssylvia  ·  3Comments