Plugin breaks GraphQL schema if CPT slug contains dash (`-`)
szaleq opened this issue · comments
Some interface type names are invalid.
For example, I have a case-study
CPT registered. This causes wp-graphql-content-blocks
to create an interface named NodeWithCase-studyEditorBlock
, which is invalid in GraphQL and causes errors. GraphiQL
doesn't load, it presents the error in the console: Uncaught (in promise) GraphQLError: Names must only contain [_a-zA-Z0-9] but "NodeWithCase-studyEditorBlocks" does not.
I believe the code responsible for this is in WPGraphQL\ContentBlocks\Type\InterfaceType\PostTypeBlockInterface
class, here and here. This code uses ucfirst
on $post_type
, which is a post slug containing a dash. I think it should rather use Utils::format_type_name
, like here in the Registry
class.
Related: a42c828
@szaleq this is already fixed and we will be publishing a new Release today.