Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type not found in document when loading Extension for composable schema #1343

Open
atlowl opened this issue Jun 19, 2023 · 3 comments
Open

Comments

@atlowl
Copy link

atlowl commented Jun 19, 2023

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.

@Kingdutch
Copy link
Contributor

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.

@atlowl
Copy link
Author

atlowl commented Jul 26, 2023

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

@Kingdutch
Copy link
Contributor

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 :)

@Kingdutch Kingdutch added the 4.x label Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants