Type not found in document when loading Extension for composable schema
atlowl opened this issue · 3 comments
I've split out my more common types into the atimintestschema.graphqls file, my thought was these get resolved in AtiSchema.php, but it doesn't seem to find them.
When the Test Event extension is enabled, those types are then not found, and i get the following error:
The website encountered an unexpected error. Please try again later.
GraphQL\Error\Error: Type "Language" not found in document. in GraphQL\Utils\BuildSchema::GraphQL\Utils\{closure}() (line 149 of /opt/vendor/webonyx/graphql-php/src/Utils/BuildSchema.php).
GraphQL\Utils\ASTDefinitionBuilder->internalBuildType('Language', Object) (Line: 194)
GraphQL\Utils\ASTDefinitionBuilder->buildType(Object) (Line: 182)
GraphQL\Utils\ASTDefinitionBuilder->buildWrappedType(Object) (Line: 155)
....
I have attached my module thats more or less a min reproduction hopefully it provides some clues.
Thanks for creating a support request! I'm very hesitant of downloading zip files from the internet, so to make it easier to help you, try reducing the scope of what you're doing to as few lines as possible which still reproduce the error and paste those in code blocks here. Or create a gist to share if you feel like you still have too much code put in an issue :D As an upside of reducing the amount of code you're reporting on, you may find what code is causing the problem and solve the issue yourself.
No worries, i didn't know about Gists's, so i've created one for this instead of the zip file.
https://gist.github.com/atlowl/1072ad0acd7623ff09d739c66a42361b
Thanks for posting the Gist! That makes it easy to find the cause :)
Your issue is using the ComposableSchema
class which overrides getSchemaDefinition
to
/**
* {@inheritdoc}
*/
protected function getSchemaDefinition() {
return <<<GQL
type Schema {
query: Query
}
type Query
GQL;
}
It does this instead of the base schema plugin class which will load the schema file with the <id>.graphqls
name that you're expecting.
The ComposableSchema
is really for situations where you don't want to define any base schema yourself but just select extensions to load. In your case (where your extensions are also specifying which schema they're extending) you want to use SdlSchemaPluginBase
:)