Description
Since PR #1203 (v1.8.0+), the Executor service is tagged with kernel.reset, and its reset() method clears $this->schemas = [].
However, addSchemaBuilder() is only called once during container compilation. After the first request in worker mode (FrankenPHP, RoadRunner), the kernel.reset event fires and permanently clears all registered schemas. Every subsequent request handled by the same worker fails with:
RuntimeException: At least one schema should be declared.
Steps to reproduce
- Use FrankenPHP in worker mode (or RoadRunner)
- Configure a GraphQL schema as usual
- Send a first request → 200 OK
- Send a second request → 500 "At least one schema should be declared."
Proof
$kernel = new App\Kernel('prod', false);
$kernel->boot();
$container = $kernel->getContainer();
$executor = $container->get('overblog_graphql.request_executor');
echo count($executor->getSchemasNames()); // 1
$kernel->handle($request);
echo count($executor->getSchemasNames()); // 1 (first request OK)
$kernel->handle($request);
echo count($executor->getSchemasNames()); // 0 ← schemas lost after reset
Root cause
In Executor.php:
public function reset(): void
{
$this->schemas = [];
}
The schemas are registered via addSchemaBuilder() calls from the compiled container, but after reset() they are never re-registered.
The same issue applies to TypeResolver::reset().
Suggested fix
The reset() method should preserve schema builders registered at compile time. For example, by saving the initial schemas and restoring them on reset:
private array $initialSchemas = [];
public function addSchemaBuilder(string $name, Closure $builder): self
{
$this->schemas[$name] = $builder;
$this->initialSchemas[$name] = $builder;
return $this;
}
public function reset(): void
{
$this->schemas = $this->initialSchemas;
}
Versions
- overblog/graphql-bundle: v1.9.0
- PHP: 8.4
- FrankenPHP: v1.12.1
- Symfony: 7.3
Workaround
Downgrade to v1.7.x (before #1203) or remove the kernel.reset tag via a compiler pass.
Description
Since PR #1203 (v1.8.0+), the
Executorservice is tagged withkernel.reset, and itsreset()method clears$this->schemas = [].However,
addSchemaBuilder()is only called once during container compilation. After the first request in worker mode (FrankenPHP, RoadRunner), thekernel.resetevent fires and permanently clears all registered schemas. Every subsequent request handled by the same worker fails with:Steps to reproduce
Proof
Root cause
In
Executor.php:The schemas are registered via
addSchemaBuilder()calls from the compiled container, but afterreset()they are never re-registered.The same issue applies to
TypeResolver::reset().Suggested fix
The
reset()method should preserve schema builders registered at compile time. For example, by saving the initial schemas and restoring them on reset:Versions
Workaround
Downgrade to v1.7.x (before #1203) or remove the
kernel.resettag via a compiler pass.