Lighthouse 教程说如果访问 /graphql-playground 会出现 GraphQL Playground 的视图,但是会抛出异常。我该如何解决?
当访问 /graphql-playground 时,抛出此异常:
InvalidArgumentException(code: 0): No hint path defined for [graphql-playground]
异常从以下位置抛出:
protected function parseNamespaceSegments($name)
{
$segments = explode(static::HINT_PATH_DELIMITER, $name);
if (count($segments) !== 2) {
throw new InvalidArgumentException("View [{$name}] has an invalid name.");
}
if (! isset($this->hints[$segments[0]])) { // <- this line
throw new InvalidArgumentException("No hint path defined for [{$segments[0]}].");
}
return $segments;
}
我试过这个:
- 将 ServiceProvider 添加到 config.app.provider
'providers' => [
//
\MLL\GraphQLPlayground\GraphQLPlaygroundServiceProvider::class,
],
- 发布包
php artisan vendor:publish --tag=graphql-playground-view
php artisan vendor:publish --tag=graphql-playground-config
php artisan vendor:publish --provider="MLL\GraphQLPlayground\GraphQLPlaygroundServiceProvider"