Skip to content

Implement AmpFutureAdapter for integration with AMPHP v3 #1900

Open
bpteam wants to merge 1 commit intowebonyx:masterfrom
bpteam:ampv3-promise-adapter-implementation
Open

Implement AmpFutureAdapter for integration with AMPHP v3 #1900
bpteam wants to merge 1 commit intowebonyx:masterfrom
bpteam:ampv3-promise-adapter-implementation

Conversation

@bpteam
Copy link
Copy Markdown

@bpteam bpteam commented Apr 15, 2026

This pull request adds first-class support for AMPHP v3's fiber-based async execution in the GraphQL PHP library, while maintaining compatibility with AMPHP v2. The main change is the introduction of the new AmpFutureAdapter, which allows using Amp\Future for async resolvers. The PR also includes new documentation and examples for AMPHP v3, updates to testing and composer configuration, and ensures smooth migration and compatibility.

Key changes:

AMPHP v3 Support and Async Adapter:

  • Added new AmpFutureAdapter in src/Executor/Promise/Adapter/AmpFutureAdapter.php to enable async execution using AMPHP v3's fiber-based Amp\Future, including full implementation of the required promise adapter interface.
  • Updated Promise class to support Amp\Future as a valid adopted promise type. [1] [2]

Documentation and Examples:

  • Added new AMPHP v3 usage and migration documentation (examples/04-async-php/amphp-v3/event-loop/README.md) and an example schema and HTTP server implementation for AMPHP v3 (examples/04-async-php/amphp-v3/schema.php, examples/04-async-php/amphp-v3/event-loop/graphql.php, examples/04-async-php/amphp-v3/http-server/README.md, examples/04-async-php/amphp-v3/http-server/graphql.php). [1] [2] [3] [4] [5]

Composer and Dependency Management:

  • Updated composer.json to allow installation of both AMPHP v2 and v3 for development, and improved the suggest section to clarify async resolving options. [1] [2]

Testing and QA:

  • Added a comprehensive test suite for AmpFutureAdapter (tests/Executor/Promise/AmpFutureAdapterTest.php) and improved test skipping logic for both AMPHP v2 and v3 adapters. [1] [2]
  • Updated phpstan.neon.dist to ignore errors for missing AMPHP v2 packages in relevant test and example files.

These changes collectively provide robust, documented, and tested support for async GraphQL resolvers using AMPHP v3, while preserving backward compatibility and developer guidance for both versions.

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.

1 participant