docz:build - Cannot query field "allDoczEntries" on type "Query"

Created on 16 Apr 2020  路  12Comments  路  Source: doczjs/docz

Bug Report

Describe the bug

 ERROR #85923  GRAPHQL

There was an error in your GraphQL query:

Cannot query field "allDoczEntries" on type "Query".

When on Windows*: Running npm run docz:build results in the error described below.

*Bug is not experienced when running on MacOS Mojave

To Reproduce

  1. With the default npm scripts, run npm run docz:build (which runs docz build)


Console output:

D:\projects\my-project\app\web>npm run docz:build

> [email protected] docz:build D:\projects\my-project\app\web
> docz build


> docz-app@ build D:\projects\my-project\app\web\.docz
> gatsby build "--prefix-paths"

warn Configuring yargs through package.json is deprecated and will be removed in

success open and validate gatsby-configs - 1.259s
success load plugins - 0.710s
success onPreInit - 0.004s
success delete html and css files from previous builds - 0.024s
success initialize cache - 0.014s
success copy gatsby files - 0.095s
success onPreBootstrap - 0.933s
success createSchemaCustomization - 0.006s
warn Configuring yargs through package.json is deprecated and will be removed in

success source and transform nodes - 5.384s
success building schema - 0.648s
success createPages - 0.002s

 ERROR #85923  GRAPHQL

There was an error in your GraphQL query:

Cannot query field "allDoczEntries" on type "Query".

If you don't expect "allDoczEntries" to exist on the type "Query" it is most lik
ely a typo.
However, if you expect "allDoczEntries" to exist there are a couple of solutions
 to common problems:

- If you added a new data source and/or changed something inside gatsby-node.js/
gatsby-config.js, please try a restart of your development server
- The field might be accessible in another subfield, please try your query in Gr
aphiQL and use the GraphiQL explorer to see which fields you can query and what
shape they have
- You want to optionally use your field "allDoczEntries" and right now it is not
 used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL
schema. A quick fix is to add a least one entry with that field ("dummy content"
)

It is recommended to explicitly type your GraphQL schema if you want to use opti
onal fields. This way you don't have to add the mentioned "dummy content". Visit
 our docs to learn how you can define the schema for "Query":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: ..\node_modules\gatsby-theme-docz\lib\createPagesStatefully.js:28:10

not finished createPagesStatefully - 0.100s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! docz-app@ build: `gatsby build "--prefix-paths"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the docz-app@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jpeterson\AppData\Roaming\npm-cache\_logs\2020-04-15T22_07
_24_337Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] docz:build: `docz build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] docz:build script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jpeterson\AppData\Roaming\npm-cache\_logs\2020-04-15T22_07
_24_465Z-debug.log

Expected behavior

I expect the docs to build successfully

Environment

  • docz version: ^2.3.1
  • OS: Windows Server 2012
  • Node/npm version: Node 12.16.2/npm 6.14.4
docz-core stale windows

Most helpful comment

had the same issue,
tried the solution from @andrwo and it worked 馃憤

switched from

files: '**/*.{mdx}',

to

files: '**/*.mdx',

All 12 comments

I am having the same issue. This appeared after updating react-scripts (CRA) to 3.4.x. Windows platform as well.

Going by the error:

You want to optionally use your field "allDoczEntries" and right now it is not
used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL
schema. A quick fix is to add a least one entry with that field ("dummy content")

Could it be that the somehow no nodes are being sourced somewhere during setup? This is a guess based on the following code where _Gatsby_ is creating nodes based on Entries but returning null when no entry:

https://github.com/doczjs/docz/blob/c7da16ba26252e80c7a044ef209e1d497cb34322/core/gatsby-theme-docz/lib/sourceNodes.js#L51-L67

I have the same error on Windows platform when running docz dev , but it's ok on Linux

I have a hunch that it has to do something with paths not being parsed correctly on windows which has been an issue before.

Does anyone have a reproduction-repo? Or steps? Is it when running a complete ny project or does something else need to happen?

Here is a stripped-off repo that reproduces the error:

https://github.com/andrwo/docz-bug-repo

Just git clone https://github.com/andrwo/docz-bug-repo.git, npm install.

npm run start ==> launches React at localhost port 3000 (working)
npm run docz:dev ==> launches docz at port 4010 (hits GraphQL error)

Hope you can look into this ... quite a showstopper for us! Thanks.

Platform: Windows 10
Node Version : v10.15.3

Additional info: I found that when i remove the 'files' setting from doczrc.js, the error went away!

Thanks for the info and repo, helps a lot 馃憤 I will have time tomorrow to dive into this, hopefully will get to the bottom of it then.

After more testing, I can narrow it down (at least, in my case) to an issue with the Glob file matching on single item brace { x } for files:

files: 'docz/**/*.{mdx}', => fails (in the repo)
files: 'docz/**/*.mdx', => works
files: '**/*.mdx', => works
files: 'docz/**/*.{md,markdown,mdx}', => works
files: '**/*.{md,mdx}', => works
files: 'docz/**/*.{md}', => fails
files: '**/*.{md}', => fails

Not sure if this is the same case for the others.

Very sorry that I can't share my repro case, but I agree with the idea that its likely in the Windows file path parsing.

I worked around the issue by removing:

src: './docs'

and using ignore to essentially blacklist markdown files instead of whitelisting them.

had the same issue,
tried the solution from @andrwo and it worked 馃憤

switched from

files: '**/*.{mdx}',

to

files: '**/*.mdx',

Thanks @andrwo :smile:

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

pedronauck picture pedronauck  路  68Comments

ronghang picture ronghang  路  33Comments

bugzpodder picture bugzpodder  路  26Comments

tamagokun picture tamagokun  路  23Comments

molebox picture molebox  路  40Comments