Implement AmpFutureAdapter for integration with AMPHP v3 #1900
Open
bpteam wants to merge 1 commit intowebonyx:masterfrom
Open
Implement AmpFutureAdapter for integration with AMPHP v3 #1900bpteam wants to merge 1 commit intowebonyx:masterfrom
bpteam wants to merge 1 commit intowebonyx:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 usingAmp\Futurefor 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:
AmpFutureAdapterinsrc/Executor/Promise/Adapter/AmpFutureAdapter.phpto enable async execution using AMPHP v3's fiber-basedAmp\Future, including full implementation of the required promise adapter interface.Promiseclass to supportAmp\Futureas a valid adopted promise type. [1] [2]Documentation and Examples:
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:
composer.jsonto allow installation of both AMPHP v2 and v3 for development, and improved thesuggestsection to clarify async resolving options. [1] [2]Testing and QA:
AmpFutureAdapter(tests/Executor/Promise/AmpFutureAdapterTest.php) and improved test skipping logic for both AMPHP v2 and v3 adapters. [1] [2]phpstan.neon.distto 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.