1. In Lighthouse 5, the error occurs: Failed to find class Modules\\ThemeStore\\Validators\\ThemeAsset\\CreateThemeAssetInputValidator in namespaces [App\\GraphQL\\Validators] for directive @validator. As shown in Figure 1
![In Lighthouse 5, the error occurs: Failed to find class Modules\\ThemeStore\\Validators\\ThemeAsset\\CreateThemeAssetInputValidator in namespaces [App\\GraphQL\\Validators] for directive @validator.](https://media.shuijingwanwq.com/2022/06/1-16.png)
Plaintext
PS E:\wwwroot\object> php artisan lighthouse:ide-helper
Wrote schema directive definitions to E:\wwwroot\object/schema-directives.graphql.
Nuwave\Lighthouse\Exceptions\DefinitionException : Failed to find class Modules\ThemeStore\Validators\ThemeAsset\CreateThemeAssetInputValidator in namespaces [App\GraphQL\Validators] for directive @validator.
at E:\wwwroot\object\vendor\nuwave\lighthouse\src\Schema\Directives\BaseDirective.php:200
196| );
197|
198| if (! $className) {
199| $consideredNamespaces = implode(', ', $namespacesToTry);
> 200| throw new DefinitionException(
201| "Failed to find class {$classCandidate} in namespaces [{$consideredNamespaces}] for directive @{$this->name()}."
202| );
203| }
204|
Exception trace:
1 Nuwave\Lighthouse\Schema\Directives\BaseDirective::namespaceClassName("Modules\ThemeStore\Validators\ThemeAsset\CreateThemeAssetInputValidator", Object(Closure))
E:\wwwroot\object\vendor\nuwave\lighthouse\src\Validation\ValidatorDirective.php:151
2 Nuwave\Lighthouse\Validation\ValidatorDirective::namespaceValidatorClass("Modules\ThemeStore\Validators\ThemeAsset\CreateThemeAssetInputValidator")
E:\wwwroot\object\vendor\nuwave\lighthouse\src\Validation\ValidatorDirective.php:124
Please use the argument -v to see more details.
2. Confirm that the class Modules\\ThemeStore\\Validators\\ThemeAsset\\CreateThemeAssetInputValidator has been migrated to Modules\\ThemeStoreGraphQl\\Validators\\ThemeAsset\\CreateThemeAssetInputValidator. As shown in Figure 2

3. After adjusting the class file path in the @validator directive to: Modules\\ThemeStoreGraphQl\\Validators\\ThemeAsset\\CreateThemeAssetInputValidator, the error no longer occurs.
GraphQL
input ThemeAssetCreateInput @validator(class: "Modules\\ThemeStore\\Validators\\ThemeAsset\\CreateThemeAssetInputValidator") {
"主题ID"
themeId: String!,
"内容"
content: String!,
"路径,相对于主题的路径,如 pages/index.blade.php"
key: String!,
}
