From beaa8069374e851275776dbdac786e7ef7eb377e Mon Sep 17 00:00:00 2001 From: Christophe VERGNE Date: Fri, 6 Jun 2025 12:03:50 +0200 Subject: [PATCH 1/4] test: Add test for CustomType with StaticTypeMapper --- tests/Fixtures/Types/CustomOutputType.php | 8 ++++++++ tests/Fixtures/config/services.yaml | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 tests/Fixtures/Types/CustomOutputType.php diff --git a/tests/Fixtures/Types/CustomOutputType.php b/tests/Fixtures/Types/CustomOutputType.php new file mode 100644 index 0000000..2cd7eaa --- /dev/null +++ b/tests/Fixtures/Types/CustomOutputType.php @@ -0,0 +1,8 @@ + Date: Fri, 6 Jun 2025 12:14:48 +0200 Subject: [PATCH 2/4] fix: Move StaticTypeMapper definition from XML to CompilerPass --- src/DependencyInjection/GraphQLiteCompilerPass.php | 13 +++++-------- src/Resources/config/container/graphqlite.xml | 4 ---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/DependencyInjection/GraphQLiteCompilerPass.php b/src/DependencyInjection/GraphQLiteCompilerPass.php index 413eed5..be3fe19 100644 --- a/src/DependencyInjection/GraphQLiteCompilerPass.php +++ b/src/DependencyInjection/GraphQLiteCompilerPass.php @@ -271,14 +271,11 @@ public function process(ContainerBuilder $container): void } } - if (!empty($customTypes)) { - $definition = $container->getDefinition(StaticTypeMapper::class); - $definition->addMethodCall('setTypes', [$customTypes]); - } - if (!empty($customNotMappedTypes)) { - $definition = $container->getDefinition(StaticTypeMapper::class); - $definition->addMethodCall('setNotMappedTypes', [$customNotMappedTypes]); - } + $staticMapperDefinition = new Definition(StaticTypeMapper::class, [ + '$types' => $customTypes, + '$notMappedTypes' => $customNotMappedTypes + ]); + $container->setDefinition('graphql.type_mapper', $staticMapperDefinition); // Register graphql.queryprovider $this->mapAdderToTag('graphql.queryprovider', 'addQueryProvider', $container, $schemaFactory); diff --git a/src/Resources/config/container/graphqlite.xml b/src/Resources/config/container/graphqlite.xml index 545ec0e..984caa7 100644 --- a/src/Resources/config/container/graphqlite.xml +++ b/src/Resources/config/container/graphqlite.xml @@ -79,10 +79,6 @@ - - - - From edb430e3f1316f91a69a38c9254dd1abebe79764 Mon Sep 17 00:00:00 2001 From: Christophe VERGNE Date: Fri, 6 Jun 2025 15:06:38 +0200 Subject: [PATCH 3/4] Add tag to StaticMapperDefintion and fix service id --- src/DependencyInjection/GraphQLiteCompilerPass.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DependencyInjection/GraphQLiteCompilerPass.php b/src/DependencyInjection/GraphQLiteCompilerPass.php index be3fe19..75246d6 100644 --- a/src/DependencyInjection/GraphQLiteCompilerPass.php +++ b/src/DependencyInjection/GraphQLiteCompilerPass.php @@ -275,7 +275,8 @@ public function process(ContainerBuilder $container): void '$types' => $customTypes, '$notMappedTypes' => $customNotMappedTypes ]); - $container->setDefinition('graphql.type_mapper', $staticMapperDefinition); + $staticMapperDefinition->addTag('graphql.type_mapper'); + $container->setDefinition(StaticTypeMapper::class, $staticMapperDefinition); // Register graphql.queryprovider $this->mapAdderToTag('graphql.queryprovider', 'addQueryProvider', $container, $schemaFactory); From 833ed7118e9d47f2fdfe042003a7a55eedcfb89d Mon Sep 17 00:00:00 2001 From: Christophe VERGNE Date: Fri, 6 Jun 2025 16:12:33 +0200 Subject: [PATCH 4/4] fix: Fix fixtures for custom output type --- tests/Fixtures/Entities/Book.php | 17 ++++++++++++++++ tests/Fixtures/Types/CustomBookType.php | 24 +++++++++++++++++++++++ tests/Fixtures/Types/CustomOutputType.php | 8 -------- tests/Fixtures/config/services.yaml | 4 ++-- 4 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 tests/Fixtures/Entities/Book.php create mode 100644 tests/Fixtures/Types/CustomBookType.php delete mode 100644 tests/Fixtures/Types/CustomOutputType.php diff --git a/tests/Fixtures/Entities/Book.php b/tests/Fixtures/Entities/Book.php new file mode 100644 index 0000000..d7e016d --- /dev/null +++ b/tests/Fixtures/Entities/Book.php @@ -0,0 +1,17 @@ +title; + } +} \ No newline at end of file diff --git a/tests/Fixtures/Types/CustomBookType.php b/tests/Fixtures/Types/CustomBookType.php new file mode 100644 index 0000000..e883dc6 --- /dev/null +++ b/tests/Fixtures/Types/CustomBookType.php @@ -0,0 +1,24 @@ + 'Book', + 'description' => 'A book', + 'fields' => [ + 'title' => [ + 'type' => Type::nonNull(Type::string()), + 'description' => 'Book title', + ], + ], + ]); + } + +} \ No newline at end of file diff --git a/tests/Fixtures/Types/CustomOutputType.php b/tests/Fixtures/Types/CustomOutputType.php deleted file mode 100644 index 2cd7eaa..0000000 --- a/tests/Fixtures/Types/CustomOutputType.php +++ /dev/null @@ -1,8 +0,0 @@ -