diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5b09fa..9447b6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['8.3'] + php-version: ['8.3', '8.4', '8.5'] symfony-version: ['6.4.*', '7.*', '8.*'] steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a9759f..dbb1e14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +3.1.0 + +- extend php version support +- add support php v8.3+ +- integrate ampphp executor + 3.0.0 - Upgrade base lib to 3.0 with breaking changes diff --git a/README.md b/README.md index bca8a56..864ec49 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Symfony bundle for [Flexible Graphql PHP](https://github.com/axtiva/flexible-gra - Fast integration to any project without breaking changes - Lazy loading on schema definition - Apollo Federation Support +- Amphp v3 support for async executions - Executable directives - Support symfony native opcache preload file generation diff --git a/composer.json b/composer.json index f9fc480..4adafb4 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ }, "require": { "php": "^8.3", - "axtiva/flexible-graphql-php": "^3.0.1", + "axtiva/flexible-graphql-php": "^3.0.2", "symfony/console": "^6.4 | ^7.0 | ^8.0", "symfony/config": "^6.4 | ^7.0 | ^8.0", "symfony/dependency-injection": "^6.4 | ^7.0 | ^8.0", @@ -26,6 +26,10 @@ }, "require-dev": { "phpstan/phpstan": "^2.1", - "phpunit/phpunit": "^12" + "phpunit/phpunit": "^12", + "amphp/amp": "^3" + }, + "suggest": { + "amphp/amp": "Needed for async execution support" } } diff --git a/src/Command/GenerateFieldResolverCommand.php b/src/Command/GenerateFieldResolverCommand.php index 8505578..070dd66 100644 --- a/src/Command/GenerateFieldResolverCommand.php +++ b/src/Command/GenerateFieldResolverCommand.php @@ -29,7 +29,7 @@ public function __construct( $this->codeGeneratorBuilder = $codeGeneratorBuilder; } - protected function configure() + protected function configure(): void { $this ->setDescription('generate field resolver') diff --git a/src/Command/GenerateScalarResolverCommand.php b/src/Command/GenerateScalarResolverCommand.php index 8606955..530282a 100644 --- a/src/Command/GenerateScalarResolverCommand.php +++ b/src/Command/GenerateScalarResolverCommand.php @@ -29,7 +29,7 @@ public function __construct( $this->codeGeneratorBuilder = $codeGeneratorBuilder; } - protected function configure() + protected function configure(): void { $this ->setDescription('generate custom scalar resolver') diff --git a/src/Command/GenerateTypeRegistryCommand.php b/src/Command/GenerateTypeRegistryCommand.php index a7c2f5c..d67098f 100644 --- a/src/Command/GenerateTypeRegistryCommand.php +++ b/src/Command/GenerateTypeRegistryCommand.php @@ -31,7 +31,7 @@ public function __construct( $this->codeGeneratorBuilder = $codeGeneratorBuilder; } - protected function configure() + protected function configure(): void { $this ->setDescription('generate type registry class for lazy load schema') diff --git a/src/DependencyInjection/FlexibleGraphqlExtension.php b/src/DependencyInjection/FlexibleGraphqlExtension.php index 9fbefaf..3fafb87 100644 --- a/src/DependencyInjection/FlexibleGraphqlExtension.php +++ b/src/DependencyInjection/FlexibleGraphqlExtension.php @@ -260,28 +260,28 @@ private function registerCommands(array $config, ContainerBuilder $container): v new Reference(TypeRegistryGeneratorBuilderInterface::class), new Reference(CodeGeneratorBuilderInterface::class), ]) - ->addTag('console.command', ['command' => GenerateTypeRegistryCommand::getDefaultName()]); + ->addTag('console.command'); $container->register(GenerateDirectiveResolverCommand::class) ->setArguments([ $config['schema_files'], new Reference(CodeGeneratorBuilderInterface::class), ]) - ->addTag('console.command', ['command' => GenerateDirectiveResolverCommand::getDefaultName()]); + ->addTag('console.command'); $container->register(GenerateFieldResolverCommand::class) ->setArguments([ $config['schema_files'], new Reference(CodeGeneratorBuilderInterface::class), ]) - ->addTag('console.command', ['command' => GenerateFieldResolverCommand::getDefaultName()]); + ->addTag('console.command'); $container->register(GenerateScalarResolverCommand::class) ->setArguments([ $config['schema_files'], new Reference(CodeGeneratorBuilderInterface::class), ]) - ->addTag('console.command', ['command' => GenerateScalarResolverCommand::getDefaultName()]); + ->addTag('console.command'); } /** diff --git a/tests/DependencyInjection/FlexibleGraphqlExtensionTest.php b/tests/DependencyInjection/FlexibleGraphqlExtensionTest.php index fdc0b8c..fe33e87 100644 --- a/tests/DependencyInjection/FlexibleGraphqlExtensionTest.php +++ b/tests/DependencyInjection/FlexibleGraphqlExtensionTest.php @@ -91,6 +91,7 @@ public static function provideBuilderVariants(): iterable { yield 'sync graphql' => ['graphql', 'sync', TypeRegistryGeneratorBuilder::class, null]; yield 'amphp v2 graphql' => ['graphql', 'amphp_v2', TypeRegistryGeneratorBuilder::class, TypeRegistryGeneratorBuilderAmphpV2::class]; + yield 'amphp v3 graphql' => ['graphql', 'amphp_v3', TypeRegistryGeneratorBuilder::class, TypeRegistryGeneratorBuilderAmphp::class]; yield 'amphp v3 federation' => ['federation', 'amphp_v3', TypeRegistryGeneratorBuilderFederated::class, TypeRegistryGeneratorBuilderAmphp::class]; } diff --git a/tests/E2e/FixtureAppConsoleTest.php b/tests/E2e/FixtureAppConsoleTest.php index 05a9d48..5cc4904 100644 --- a/tests/E2e/FixtureAppConsoleTest.php +++ b/tests/E2e/FixtureAppConsoleTest.php @@ -62,6 +62,22 @@ public function testFixtureAppGenerationSupportsConfigurationVariantsAndFederati self::assertStringContainsString('directive_federation__shareable', $registryCode); } + public function testFixtureAppGenerationSupportsAmphpV3Executor(): void + { + $registryFile = self::fixtureAppDir() . '/var/generated/TypeRegistry.php'; + + $this->runConsoleCommand('flexible_graphql:generate-type-registry', [ + 'FLEXIBLE_GRAPHQL_EXECUTOR' => 'amphp_v3', + 'FLEXIBLE_GRAPHQL_SCHEMA_TYPE' => 'graphql', + ]); + self::assertFileExists($registryFile); + + $registryCode = (string) file_get_contents($registryFile); + self::assertStringContainsString('\Amp\async(', $registryCode, 'AMP v3 executor must wrap resolvers with \Amp\async()'); + self::assertStringNotContainsString('\Amp\call(', $registryCode, 'AMP v3 executor must not use \Amp\call() (that is the v2 API)'); + self::assertStringContainsString('ServiceCollectionInterface', $registryCode); + } + public function testGeneratedTypeRegistryUsesScopedLocatorOnly(): void { $registryFile = self::fixtureAppDir() . '/var/generated/TypeRegistry.php'; @@ -84,7 +100,6 @@ public function testGeneratedTypeRegistryUsesScopedLocatorOnly(): void self::assertSame(ServiceCollectionInterface::class, $constructorType->getName()); $getService = new ReflectionMethod($registryClass, 'getService'); - $getService->setAccessible(true); self::assertIsObject($getService->invoke($registry, $serviceId));