Skip to content

Commit

Permalink
📦 Use dev-master for graphqlite because of improved performance, dr…
Browse files Browse the repository at this point in the history
…opped support for doctrine annotations. Drop support for doctrine annotations
  • Loading branch information
andrew-demb committed Nov 16, 2024
1 parent ff06ee1 commit a1dfb6e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
"require" : {
"php" : ">=8.1",
"ext-json": "*",
"thecodingmachine/graphqlite" : "^7.0",
"thecodingmachine/graphqlite" : "dev-master as 7.1",
"thecodingmachine/graphqlite-symfony-validator-bridge": "^6.0 || ^7.0",
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/validator": "^6.4 || ^7.0",
"symfony/translation": "^6.4 || ^7.0",
"doctrine/annotations": "^1.13 || ^2.0.1",
"symfony/psr-http-message-bridge": "^6.4 || ^7.0",
"nyholm/psr7": "^1.1",
"laminas/laminas-diactoros": "^2.2 || ^3.0",
Expand All @@ -50,7 +49,7 @@
"phpstan": "phpstan analyse GraphQLiteBundle.php DependencyInjection/ Controller/ Resources/ Security/ -c phpstan.neon --level=7 --no-progress"
},
"suggest": {
"symfony/security-bundle": "To use @Logged or @Right annotations"
"symfony/security-bundle": "To use #[Logged] or #[Right] attributes"
},
"autoload" : {
"psr-4" : {
Expand Down
23 changes: 3 additions & 20 deletions src/DependencyInjection/GraphQLiteCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

namespace TheCodingMachine\GraphQLite\Bundle\DependencyInjection;

use Doctrine\Common\Annotations\AnnotationReader as DoctrineAnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\Annotations\PsrCachedReader;
use Generator;
use GraphQL\Server\ServerConfig;
use GraphQL\Validator\Rules\DisableIntrospection;
Expand Down Expand Up @@ -59,7 +56,7 @@
class GraphQLiteCompilerPass implements CompilerPassInterface
{
/**
* @var AnnotationReader
* @var AnnotationReader|null
*/
private $annotationReader;

Expand Down Expand Up @@ -422,26 +419,12 @@ private static function getParametersByName(ReflectionMethod $method): array
}

/**
* Returns a cached Doctrine annotation reader.
* Returns a GraphQLite annotation reader.
* Note: we cannot get the annotation reader service in the container as we are in a compiler pass.
*/
private function getAnnotationReader(): AnnotationReader
{
if ($this->annotationReader === null) {
// @phpstan-ignore-next-line "registerLoader exists in doctrine/annotations:v1.x"
if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
AnnotationRegistry::registerLoader('class_exists');
}

$doctrineAnnotationReader = new DoctrineAnnotationReader();

if (ApcuAdapter::isSupported()) {
$doctrineAnnotationReader = new PsrCachedReader($doctrineAnnotationReader, new ApcuAdapter('graphqlite'), true);
}

$this->annotationReader = new AnnotationReader(/*$doctrineAnnotationReader, AnnotationReader::LAX_MODE*/);
}
return $this->annotationReader;
return $this->annotationReader ??= new AnnotationReader();
}

/**
Expand Down
8 changes: 1 addition & 7 deletions src/Resources/config/container/graphqlite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd"
>
<parameters>
<parameter key="graphqlite.annotations.error_mode">LAX_MODE</parameter>
</parameters>

<services>
<defaults autowire="true" autoconfigure="true" public="false" />

Expand Down Expand Up @@ -40,9 +36,7 @@
<service id="GraphQL\Type\Schema" alias="TheCodingMachine\GraphQLite\Schema" />


<service id="TheCodingMachine\GraphQLite\AnnotationReader" >
<argument key="$mode">%graphqlite.annotations.error_mode%</argument>
</service>
<service id="TheCodingMachine\GraphQLite\AnnotationReader" />

<service id="TheCodingMachine\GraphQLite\Bundle\Security\AuthenticationService">
<argument type="service" id="security.token_storage" on-invalid="null" />
Expand Down

0 comments on commit a1dfb6e

Please # to comment.