diff --git a/src/DependencyInjection/GraphQLiteCompilerPass.php b/src/DependencyInjection/GraphQLiteCompilerPass.php
index 413eed5..75246d6 100644
--- a/src/DependencyInjection/GraphQLiteCompilerPass.php
+++ b/src/DependencyInjection/GraphQLiteCompilerPass.php
@@ -271,14 +271,12 @@ 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
+ ]);
+ $staticMapperDefinition->addTag('graphql.type_mapper');
+ $container->setDefinition(StaticTypeMapper::class, $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 @@
-
-
-
-
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/config/services.yaml b/tests/Fixtures/config/services.yaml
index c8fb6f5..789b136 100644
--- a/tests/Fixtures/config/services.yaml
+++ b/tests/Fixtures/config/services.yaml
@@ -20,6 +20,10 @@ services:
TheCodingMachine\GraphQLite\Bundle\Tests\NoSecurityBundleFixtures\:
resource: '../../NoSecurityBundleFixtures/*'
+ TheCodingMachine\Graphqlite\Bundle\Tests\Fixtures\Types\CustomBookType:
+ tags:
+ - { name: 'graphql.output_type', class: 'TheCodingMachine\GraphQLite\Bundle\Tests\Fixtures\Entities\Book' }
+
someService:
class: stdClass