尝试将 laravel lighthouse-php 与 Roadrunner Server 结合使用时遇到间歇性错误

jak*_*wns 5 php laravel laravel-lighthouse

  • 走鹃 1.8.1
  • 拉拉维尔:7.17.2
  • 灯塔:4.15.0

使用 NGINX 时,我的 GraphQL API/架构没有任何问题。然而,当我切换到 Roadrunner 时,我突然间歇性地收到如下错误:

"message": "Lighthouse failed while trying to load a type: MyType\n\nMake sure the type is present in your schema definition.\n",
    "exception": "Nuwave\\Lighthouse\\Exceptions\\DefinitionException",
    "file": "/var/www/wright/ams/vendor/nuwave/lighthouse/src/Schema/TypeRegistry.php",
    "line": 94
Run Code Online (Sandbox Code Playgroud)

有其他人经历过这个并找到解决方案吗?

我确实启用了 opcache,但即使禁用了它,我仍然遇到这个问题。

我运行了 php artisan lighthouse:validate-schema,它是有效的 我也运行了 php artisan lighthouse:clear-cache,但无济于事

Sam*_*uel 3

我怀疑这可能与 Lighthouse 使用的模式缓存有关。如果您正在部署具有新类型的架构但保留旧的缓存,那么我怀疑您会看到这样的错误。

解决方案是使用 Artisan 命令清除灯塔缓存lighthouse:clear-cache