Gatsby: file system routing: Incorrect output type string

Created on 4 Sep 2020  ·  11Comments  ·  Source: gatsbyjs/gatsby

Description

"build-schema" throws an error complaining about the output type of "WpPost.gatsbyPath".

success source and transform nodes - 6.842s
⠦ building schema

 ERROR 
Missing onError handler for invocation 'building-schema', error was 'Error: WpPost.gatsbyPath provided incorrect OutputType: 'String''. Stacktrace was 'Error: WpPost.gatsbyPath provided incorrect OutputType: 'String'                                                                                                                                                                                                            tring'
    at TypeMapper.convertOutputFieldConfig (C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\TypeMapper.js:294:15)
    at resolveOutputConfigAsThunk (C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\utils\configAsThunk.js:19:41)
    at ObjectTypeComposer.getFieldConfig (C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\ObjectTypeComposer.js:300:58)
    at C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\utils\toInputObjectType.js:44:19
    at Array.forEach (<anonymous>)
    at toInputObjectType (C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\utils\toInputObjectType.js:38:14)
    at convertInputObjectField (C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\utils\toInputObjectType.js:78:19)
    at C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\utils\toInputObjectType.js:45:23
    at Array.forEach (<anonymous>)
    at toInputObjectType (C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\utils\toInputObjectType.js:38:14)
    at convertInputObjectField (C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\utils\toInputObjectType.js:78:19)
    at C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\utils\toInputObjectType.js:45:23
    at Array.forEach (<anonymous>)
    at toInputObjectType (C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\utils\toInputObjectType.js:38:14)
    at convertInputObjectField (C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\utils\toInputObjectType.js:78:19)
    at C:\Users\Alex\code\moonmeister\moonmeister.net\node_modules\gatsby\node_modules\graphql-compose\lib\utils\toInputObjectType.js:45:23'
⠏ building schema

Steps to reproduce

https://github.com/moonmeister/moonmeister.net/tree/refactor/unified-routes

Expected result

Should build pages using the URI from the WordPress source plugin

Actual result

Throws this error. I've tried using slug, and title as well. all to the same affect. I've used file-system routing on 2 other sites with no troubles...so this confuses me.

Environment

System:
OS: Windows 10 10.0.19042
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Binaries:
Node: 12.18.3 - ~\AppData\Local\Temp\yarn--1599212003520-0.293080228882421\node.CMD
Yarn: 1.22.5 - ~\AppData\Local\Temp\yarn--1599212003520-0.293080228882421\yarn.CMD
npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD
Languages:
Python: 3.8.5
Browsers:
Chrome: 85.0.4183.83
Edge: Spartan (44.19041.423.0), Chromium (85.0.564.44)
npmPackages:
gatsby: ^2.24.53 => 2.24.53
gatsby-image: ^2.4.16 => 2.4.16
gatsby-plugin-feed: ^2.5.11 => 2.5.11
gatsby-plugin-goatcounter: ^0.4.0 => 0.4.0
gatsby-plugin-linaria: ^2.1.0 => 2.1.0
gatsby-plugin-manifest: ^2.4.27 => 2.4.27
gatsby-plugin-netlify: ^2.3.13 => 2.3.13
gatsby-plugin-offline: ^3.2.26 => 3.2.26
gatsby-plugin-postcss: ^2.3.11 => 2.3.11
gatsby-plugin-preact: ^4.0.10 => 4.0.10
gatsby-plugin-react-helmet: ^3.3.10 => 3.3.10
gatsby-plugin-readingtime: ^1.0.1 => 1.0.1
gatsby-plugin-robots-txt: ^1.5.1 => 1.5.1
gatsby-plugin-sharp: ^2.6.31 => 2.6.31
gatsby-plugin-sitemap: ^2.4.12 => 2.4.12
gatsby-plugin-webpack-bundle-analyzer: ^1.0.5 => 1.0.5
gatsby-plugin-webpack-size: ^1.0.0 => 1.0.0
gatsby-source-filesystem: ^2.3.27 => 2.3.27
gatsby-source-wordpress-experimental: ^1.3.8 => 1.3.8
gatsby-transformer-sharp: ^2.5.14 => 2.5.14
npmGlobalPackages:
gatsby-cli: 2.12.59

WordPress page creation bug

Most helpful comment

Not stale.

All 11 comments

Hi,

have you tried using the 'gatsby clean' cmd?
try deleting '.cache' folder completely and the content in 'public' as well

Hey. Is this specific to unified routes? Do you get the same error without it? My feeling is that the answer to this is in the wp plugin, as that's what is defining the types

My site works fine, when I tried to implement unified routes this comes up. Disabling the unified route stops this error. @TylerBarnes Any ideas?

Do uri or gatsbyPath have custom resolvers?

Everything in the WP plugin is custom resolvers but I'm not familiar with the gatsbyPath field. @moonmeister how is that added to the schema?

gatsbyPath is part of unified routes. It's how gatsby tracks what Path you put a page at so you can easily link to it. https://www.gatsbyjs.com/docs/file-system-page-creation/#routing-and-linking

I don't believe so @ascorbic but all the code is here for the collection:

https://github.com/moonmeister/moonmeister.net/blob/refactor/unified-routes/src/pages/%7BWpPost.uri%7D.js

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

Not stale.

I've encountered similar problems in the past. I think it is caused by different versions of graphql package where inappropriate is resolved for usage.

If you are using Yarn, try this resolution

"resolutions": {
    "graphql": "14.6.0",
},

I have resolved this for myself thanks to @czabaj 's comment. I ran yarn why grapphql to see what competing versions of graphql I had. All Gatsby packages were wanting graphql 14.7 but I had v15 installed as a dev dependency. I believe I did that a while back to satisfy a peer dependency requirement. But removing that revealed no peer dependency warning and solved the issue of multiple versions of graphql. Thanks for the hint.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Oppenheimer1 picture Oppenheimer1  ·  3Comments

magicly picture magicly  ·  3Comments

totsteps picture totsteps  ·  3Comments

brandonmp picture brandonmp  ·  3Comments

benstr picture benstr  ·  3Comments