Skip to content

Add ReactPhp client for non-blocking GraphQL calls#137

Open
spawnia wants to merge 5 commits intomasterfrom
add-reactphp-client
Open

Add ReactPhp client for non-blocking GraphQL calls#137
spawnia wants to merge 5 commits intomasterfrom
add-reactphp-client

Conversation

@spawnia
Copy link
Copy Markdown
Owner

@spawnia spawnia commented Mar 24, 2026

Summary

  • Adds Spawnia\Sailor\Client\ReactPhp — a non-blocking GraphQL client using react/http Browser with React\Async\await()
  • Extracted from https://gitlab.mll/services/sysmex/-/merge_requests/96 where it was validated in production
  • Structurally identical to the existing Guzzle client, making it available to any project running Sailor inside a ReactPHP event loop

Test plan

  • Unit tests pass (vendor/bin/phpunit tests/Unit/Client/ReactPhpTest.php)
  • PHPStan clean
  • CI passes

🤖 Generated with Claude Code

Extracted from https://gitlab.mll/services/sysmex/-/merge_requests/96 where it was validated in production.
Generic implementation structurally identical to the Guzzle client, using react/http Browser with React\Async\await().

🤖 Generated with Claude Code
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a ReactPHP-based Sailor HTTP client to enable GraphQL requests from within ReactPHP applications, aligning the implementation with existing built-in clients.

Changes:

  • Introduces Spawnia\Sailor\Client\ReactPhp using react/http’s Browser and React\Async\await().
  • Adds unit tests covering basic requests, variables, and non-200 response handling.
  • Updates dependencies/suggestions and documents the new built-in client in the README.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/Client/ReactPhp.php Adds a new ReactPHP-backed client implementation conforming to the existing Client interface.
tests/Unit/Client/ReactPhpTest.php Adds unit tests validating request payloads and error behavior for the new client.
composer.json Adds ReactPHP packages to require-dev and suggest for the new client.
README.md Mentions the new ReactPhp client in the built-in client list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

spawnia and others added 4 commits March 24, 2026 14:36
react/async:^4 requires PHP >= 8.1, so remove it before composer
install in CI for PHP 7.4/8.0. The test skips gracefully via
@requires when the packages are not available.

Also add composer require snippet for the ReactPHP client
in the README installation section.

🤖 Generated with Claude Code
With lowest dependencies, react/async await() returns mixed instead
of the generic type, causing a type mismatch on fromResponseInterface().
reportUnmatchedIgnoredErrors is already false so this is harmless
when running with highest dependencies.

🤖 Generated with Claude Code
🤖 Generated with Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants