Repository navigation
test(graphql): cover one resolver lock across a request's fields - #14981
Conversation
Fields of one GraphQL request share the request's resources, so they must run one at a time. Resolve three fields through the production request context and assert a field that starts after the first has finished still waits for the second. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No issues found — approved ✅. This PR is test-only: it introduces a Swoole coroutine-based fake HTTP adapter and a unit test asserting that GraphQL fields within a single request execute serially under the shared
Reviewed commit: 4724ac8 |
🟢 Tier S · Ready to merge
Adds a coroutine-local HTTP adapter for GraphQL resolver testing and a separate-process test that invokes three API resolvers using the production request context. The test checks that all fields complete and that only one route action runs at a time.
📂 Walkthrough · 2
Reviewed |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What does this PR do?
Adds a unit test for the GraphQL resolver lock that #14820 moved into the request context (
resolverLockinapp/init/resources/request.php). That PR's e2e test covers caller identity, but nothing covered the lock itself.The test registers the production request context, resolves three fields of one request through
Resolvers::api()in Swoole coroutines, and starts the third field after the first has finished while the second still holds the lock. It asserts that no two fields run at once.CoroutineServeris a minimal HTTP adapter whose context is coroutine-local, like the Swoole adapters, so each resolver coroutine gets its own child container. The test runs in a separate process becauseSwoole\Coroutine\run()leaves runtime hooks enabled for the rest of the process.Test Plan
vendor/bin/phpunit tests/unit/GraphQL/ResolversTest.phppasses onmain(3 of 3 runs).Resolvers.phpandrequest.phpchanges from acfc742 reverted, it fails in 3 of 3 runs:Failed asserting that 2 is identical to 1.--testsuite unitinappwrite/base:2.2.7shows the same results asmain. In both, the only failures are 12 errors fromKeyTestandListCacheTest, which need the stack's OpenSSL key and Redis.composer lintandphpstanon the new files both pass.Related PRs and Issues
Checklist
🤖 Generated with Claude Code