FIX: GraphQL Error — There was an error while compiling your site’s GraphQL queries.

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

Presh Onyee
2 min readOct 18, 2019

TL, DR: Make sure you have the casing on your file paths typed correctly.

This error is actually caused by a bug in Gatsby and affects certain terminals on most Windows machines.

Gatsby npm script has issues with casing names for files and directories paths on certain terminals on Windows.

The first step to fixing this is to use your default Windows terminal to run your Gatsby application.

The second option is to make sure your directory paths casing match the ones on your terminal. For example, let’s say my Gatsby project is stored on my desktop~/Desktop/myapp on my local disk, whenever I try to open the project folder from my terminal with a different name casing like ~/desktop/myapp it will result in this exact error.

This bug doesn’t make Gatsby recognize /desktop/MyNewApp and /Desktop/mynewapp as the same thing.

The easiest way is to avoid this is to first open the project folder in your file explorer and use the exact same address on your file explorer in the terminal, taking note of the letter casings.

This error can also affect your file paths in your code. For instance, you may experience this error in your gatsby-node.js file.

screenshot sample

If your blog.js file is actually in the ./src/templates/blog.js directory and you use ./src/Templates/blog.js or ./src/templates.Blog.js you’d get this same error.

Overall, make sure you have the casings on your file paths correct and you’re good to go.

Have a great day 👋🏾!

--

--

Presh Onyee

User Experience Designer sharing random thoughts on creativity and product design.