'gatsby develop' fails when wordpress site language is set to Russian: Missing onError handler for invocation 'building-schema'
Closed this issue · 3 comments
Hi!
I'm facing an error: gatsby develop
fails when site language is set to Russian id wordpress admin panel.
If I switch site language to English (UK) - gatsby develop
doesn't fail and static site is generated as expected.
Not sure if this error relates to gatsby-source-wordpress-experimental or WP Gatsby/WP GraphQL.
Environment:
- Wordpress: 5.5.3
- wp theme: twenty-twenty
- Site language: Russian
- gatsby: 2.25.0
- gatsby-source-wordpress-experimental: 7.0.3
- WP Gatsby: 0.9.2
- WP GraphQL: 1.1.3
Error message
ERROR
Missing onError handler for invocation 'building-schema', error was 'Names must
match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "WpTemplate_Шаблон обложки" does not.'.
Stacktrace was 'GraphQLError: Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but
"WpTemplate_Шаблон обложки" does not.
at isValidNameError
(C:\projects\artelx\node_modules\graphql\utilities\assertValidName.js:42:12)
at assertValidName
(C:\projects\artelx\node_modules\graphql\utilities\assertValidName.js:21:15)
at checkIsAllowedTypeName
(C:\projects\artelx\node_modules\gatsby\src\schema\schema.js:578:3)
at forEach
(C:\projects\artelx\node_modules\gatsby\src\schema\schema.js:284:9)
at Array.forEach (<anonymous>)
at addTypes
(C:\projects\artelx\node_modules\gatsby\src\schema\schema.js:246:9)
at updateSchemaComposer
(C:\projects\artelx\node_modules\gatsby\src\schema\schema.js:135:9)
at buildSchema
(C:\projects\artelx\node_modules\gatsby\src\schema\schema.js:62:9)
at build (C:\projects\artelx\node_modules\gatsby\src\schema\index.js:105:24)
at buildSchema
(C:\projects\artelx\node_modules\gatsby\src\services\build-schema.ts:19:3)'
Hi,
I suppose "WpTemplate_Шаблон обложки" is a page template that you use, and it uses Cyrillic characters. I've reproduced your issue, and it does not seem to depend on a site language, and I'm not sure how it fixes it in your case (doesn't in mine).
The problem is, WPGraphQL creates a type
for each page template, and a GraphQL type
can only be alphanumeric. WPGraphQL changes type names to make them safe, but for some reason it doesn't work with Cyrillic names at all. That's likely a bug, and it's on WPGraphQL's side.
So when graphql on Gatsby's side validates schema and finds this field, it crashes.
A workaround (only one I can come up with now) I can suggest just renaming the template (change it within the template file, without changing the file name itself). After assigning it an alphanumeric name, it works.
Thanks for the reply and investigation!
"WpTemplate_Шаблон обложки" - is a default name in twenty-twenty theme in Russian, didn't change it.
When site language is English, it works.
Most likely WPGraphQL uses msgstr for page template, and it's in Cyrilic (in case of Russian). Will check WPGraphQL for similar issue or create a new one.
For further information:
It worked fine with this configuration:
- Wordpress: 5.5.3 -> same version
- wp theme: twenty-twenty -> same version
- Site language: Russian -> the same
- gatsby: 2.24.63
- gatsby-source-wordpress-experimental: 1.4.6
- WP Gatsby: 0.4.*
- WP GraphQL: 0.3.1
Ahh, yep good investigation and this is indeed an upstream issue. It might also be worth asking about this on the Gatsby repo - WPGraphQL seems to be fine with Cyrilic characters in type names but Gatsby does not. The only thing is I'm not sure if this is coming from graphql-js
or Gatsby itself 🤔
In any case I'm going to close this because there's nothing that can be done in this plugin to fix it and either fix will be upstream. Thanks for opening this issue!