Skip to content

Commit b7682aa

Browse files
authored
Merge pull request #111 from devmaslov/graphqlite-5-upgrade
Update GraphQLite to the 5th version
2 parents a018fe4 + 068ff02 commit b7682aa

39 files changed

+254
-276
lines changed

Command/DumpSchemaCommand.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace TheCodingMachine\Graphqlite\Bundle\Command;
5+
namespace TheCodingMachine\GraphQLite\Bundle\Command;
66

7-
use GraphQL\Type\Definition\ObjectType;
7+
use GraphQL\Type\Definition\TypeWithFields;
88
use GraphQL\Utils\SchemaPrinter;
99
use Symfony\Component\Console\Command\Command;
1010
use Symfony\Component\Console\Input\InputInterface;
@@ -63,15 +63,19 @@ private function sortSchema(): void
6363
{
6464
$config = $this->schema->getConfig();
6565

66-
$refl = new \ReflectionProperty(ObjectType::class, 'fields');
66+
$refl = new \ReflectionProperty(TypeWithFields::class, 'fields');
6767
$refl->setAccessible(true);
6868

69-
$fields = $config->query->getFields();
70-
ksort($fields);
71-
$refl->setValue($config->query, $fields);
69+
if ($config->query) {
70+
$fields = $config->query->getFields();
71+
ksort($fields);
72+
$refl->setValue($config->query, $fields);
73+
}
7274

73-
$fields = $config->mutation->getFields();
74-
ksort($fields);
75-
$refl->setValue($config->mutation, $fields);
75+
if ($config->mutation) {
76+
$fields = $config->mutation->getFields();
77+
ksort($fields);
78+
$refl->setValue($config->mutation, $fields);
79+
}
7680
}
7781
}

Context/SymfonyGraphQLContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Graphqlite\Bundle\Context;
4+
namespace TheCodingMachine\GraphQLite\Bundle\Context;
55

66

77
use Symfony\Component\HttpFoundation\Request;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace TheCodingMachine\Graphqlite\Bundle\Context;
3+
namespace TheCodingMachine\GraphQLite\Bundle\Context;
44

55
use Symfony\Component\HttpFoundation\Request;
66

@@ -10,4 +10,4 @@ interface SymfonyRequestContextInterface
1010
* @return Request
1111
*/
1212
public function getRequest(): Request;
13-
}
13+
}

Controller/GraphQL/InvalidUserPasswordException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Graphqlite\Bundle\Controller\GraphQL;
4+
namespace TheCodingMachine\GraphQLite\Bundle\Controller\GraphQL;
55

66
use Exception;
77
use TheCodingMachine\GraphQLite\Exceptions\GraphQLException;

Controller/GraphQL/LoginController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace TheCodingMachine\Graphqlite\Bundle\Controller\GraphQL;
2+
namespace TheCodingMachine\GraphQLite\Bundle\Controller\GraphQL;
33

44

55
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -13,7 +13,6 @@
1313
use Symfony\Component\Security\Core\User\UserProviderInterface;
1414
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
1515
use TheCodingMachine\GraphQLite\Annotations\Mutation;
16-
use TheCodingMachine\GraphQLite\Annotations\Query;
1716

1817
class LoginController
1918
{

Controller/GraphQL/MeController.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
<?php
2-
namespace TheCodingMachine\Graphqlite\Bundle\Controller\GraphQL;
2+
namespace TheCodingMachine\GraphQLite\Bundle\Controller\GraphQL;
33

44

5-
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
6-
use Symfony\Component\HttpFoundation\Request;
7-
use Symfony\Component\HttpFoundation\Session\SessionInterface;
85
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
9-
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
10-
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
11-
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
126
use Symfony\Component\Security\Core\User\UserInterface;
13-
use Symfony\Component\Security\Core\User\UserProviderInterface;
14-
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
15-
use TheCodingMachine\GraphQLite\Annotations\Mutation;
167
use TheCodingMachine\GraphQLite\Annotations\Query;
17-
use TheCodingMachine\Graphqlite\Bundle\Types\BasicUser;
188

199
class MeController
2010
{

Controller/GraphqliteController.php renamed to Controller/GraphQLiteController.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Graphqlite\Bundle\Controller;
4+
namespace TheCodingMachine\GraphQLite\Bundle\Controller;
55

66

77
use Laminas\Diactoros\ResponseFactory;
@@ -11,9 +11,7 @@
1111
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
1212
use TheCodingMachine\GraphQLite\Http\HttpCodeDecider;
1313
use function array_map;
14-
use GraphQL\Error\Debug;
1514
use GraphQL\Executor\ExecutionResult;
16-
use GraphQL\Executor\Promise\Promise;
1715
use GraphQL\Server\ServerConfig;
1816
use GraphQL\Server\StandardServer;
1917
use GraphQL\Upload\UploadMiddleware;
@@ -27,18 +25,18 @@
2725
use Symfony\Component\HttpFoundation\Response;
2826
use Symfony\Component\Routing\Route;
2927
use Symfony\Component\Routing\RouteCollection;
30-
use TheCodingMachine\Graphqlite\Bundle\Context\SymfonyGraphQLContext;
28+
use TheCodingMachine\GraphQLite\Bundle\Context\SymfonyGraphQLContext;
3129

3230
/**
3331
* Listens to every single request and forward Graphql requests to Graphql Webonix standardServer.
3432
*/
35-
class GraphqliteController
33+
class GraphQLiteController
3634
{
3735
/**
3836
* @var HttpMessageFactoryInterface
3937
*/
4038
private $httpMessageFactory;
41-
/** @var bool|int */
39+
/** @var int */
4240
private $debug;
4341
/**
4442
* @var ServerConfig
@@ -49,7 +47,7 @@ public function __construct(ServerConfig $serverConfig, HttpMessageFactoryInterf
4947
{
5048
$this->serverConfig = $serverConfig;
5149
$this->httpMessageFactory = $httpMessageFactory ?: new PsrHttpFactory(new ServerRequestFactory(), new StreamFactory(), new UploadedFileFactory(), new ResponseFactory());
52-
$this->debug = $debug ?? $serverConfig->getDebug();
50+
$this->debug = $debug ?? $serverConfig->getDebugFlag();
5351
}
5452

5553
public function loadRoutes(): RouteCollection

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Graphqlite\Bundle\DependencyInjection;
4+
namespace TheCodingMachine\GraphQLite\Bundle\DependencyInjection;
55

66
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
77
use Symfony\Component\Config\Definition\ConfigurationInterface;

DependencyInjection/GraphqliteCompilerPass.php renamed to DependencyInjection/GraphQLiteCompilerPass.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Graphqlite\Bundle\DependencyInjection;
4+
namespace TheCodingMachine\GraphQLite\Bundle\DependencyInjection;
55

66
use Doctrine\Common\Annotations\PsrCachedReader;
77
use GraphQL\Server\ServerConfig;
@@ -47,17 +47,17 @@
4747
use TheCodingMachine\GraphQLite\Annotations\Field;
4848
use TheCodingMachine\GraphQLite\Annotations\Mutation;
4949
use TheCodingMachine\GraphQLite\Annotations\Query;
50-
use TheCodingMachine\Graphqlite\Bundle\Controller\GraphQL\LoginController;
51-
use TheCodingMachine\Graphqlite\Bundle\Controller\GraphQL\MeController;
50+
use TheCodingMachine\GraphQLite\Bundle\Controller\GraphQL\LoginController;
51+
use TheCodingMachine\GraphQLite\Bundle\Controller\GraphQL\MeController;
5252
use TheCodingMachine\GraphQLite\GraphQLRuntimeException as GraphQLException;
5353
use TheCodingMachine\GraphQLite\Mappers\StaticTypeMapper;
5454
use TheCodingMachine\GraphQLite\SchemaFactory;
55-
use TheCodingMachine\Graphqlite\Bundle\Types\SymfonyUserInterfaceType;
55+
use TheCodingMachine\GraphQLite\Bundle\Types\SymfonyUserInterfaceType;
5656

5757
/**
5858
* Detects controllers and types automatically and tag them.
5959
*/
60-
class GraphqliteCompilerPass implements CompilerPassInterface
60+
class GraphQLiteCompilerPass implements CompilerPassInterface
6161
{
6262
/**
6363
* @var AnnotationReader

DependencyInjection/GraphqliteExtension.php renamed to DependencyInjection/GraphQLiteExtension.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Graphqlite\Bundle\DependencyInjection;
4+
namespace TheCodingMachine\GraphQLite\Bundle\DependencyInjection;
55

66

7+
use GraphQL\Error\DebugFlag;
78
use TheCodingMachine\GraphQLite\Mappers\Root\RootTypeMapperFactoryInterface;
89
use function array_map;
9-
use GraphQL\Error\Debug;
1010
use GraphQL\Server\ServerConfig;
1111
use GraphQL\Type\Definition\ObjectType;
12-
use function implode;
13-
use function is_dir;
14-
use Mouf\Composer\ClassNameMapper;
1512
use function rtrim;
1613
use Symfony\Component\Config\FileLocator;
1714
use Symfony\Component\DependencyInjection\ContainerBuilder;
18-
use Symfony\Component\DependencyInjection\Definition;
1915
use Symfony\Component\DependencyInjection\Extension\Extension;
2016
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
21-
use TheCodingMachine\GraphQLite\GraphQLRuntimeException as GraphQLException;
22-
use function var_dump;
2317

24-
class GraphqliteExtension extends Extension
18+
class GraphQLiteExtension extends Extension
2519
{
2620

21+
public function getAlias()
22+
{
23+
return 'graphqlite';
24+
}
25+
2726
/**
2827
* Loads a specific configuration.
2928
*
@@ -84,9 +83,9 @@ function($namespace): string {
8483
if (isset($config['debug'])) {
8584
$debugCode = $this->toDebugCode($config['debug']);
8685
} else {
87-
$debugCode = Debug::RETHROW_UNSAFE_EXCEPTIONS;
86+
$debugCode = DebugFlag::RETHROW_UNSAFE_EXCEPTIONS;
8887
}
89-
$definition->addMethodCall('setDebug', [$debugCode]);
88+
$definition->addMethodCall('setDebugFlag', [$debugCode]);
9089

9190
$container->registerForAutoconfiguration(ObjectType::class)
9291
->addTag('graphql.output_type');
@@ -101,10 +100,10 @@ function($namespace): string {
101100
private function toDebugCode(array $debug): int
102101
{
103102
$code = 0;
104-
$code |= ($debug['INCLUDE_DEBUG_MESSAGE'] ?? 0)*Debug::INCLUDE_DEBUG_MESSAGE;
105-
$code |= ($debug['INCLUDE_TRACE'] ?? 0)*Debug::INCLUDE_TRACE;
106-
$code |= ($debug['RETHROW_INTERNAL_EXCEPTIONS'] ?? 0)*Debug::RETHROW_INTERNAL_EXCEPTIONS;
107-
$code |= ($debug['RETHROW_UNSAFE_EXCEPTIONS'] ?? 0)*Debug::RETHROW_UNSAFE_EXCEPTIONS;
103+
$code |= ($debug['INCLUDE_DEBUG_MESSAGE'] ?? 0)*DebugFlag::INCLUDE_DEBUG_MESSAGE;
104+
$code |= ($debug['INCLUDE_TRACE'] ?? 0)*DebugFlag::INCLUDE_TRACE;
105+
$code |= ($debug['RETHROW_INTERNAL_EXCEPTIONS'] ?? 0)*DebugFlag::RETHROW_INTERNAL_EXCEPTIONS;
106+
$code |= ($debug['RETHROW_UNSAFE_EXCEPTIONS'] ?? 0)*DebugFlag::RETHROW_UNSAFE_EXCEPTIONS;
108107
return $code;
109108
}
110109
}

DependencyInjection/OverblogGraphiQLEndpointWiringPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
namespace TheCodingMachine\Graphqlite\Bundle\DependencyInjection;
3+
namespace TheCodingMachine\GraphQLite\Bundle\DependencyInjection;
44

55
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
66
use Symfony\Component\DependencyInjection\ContainerBuilder;
77
use Symfony\Component\DependencyInjection\Definition;
88
use Symfony\Component\DependencyInjection\Reference;
9-
use TheCodingMachine\Graphqlite\Bundle\GraphiQL\EndpointResolver;
9+
use TheCodingMachine\GraphQLite\Bundle\GraphiQL\EndpointResolver;
1010

1111
final class OverblogGraphiQLEndpointWiringPass implements CompilerPassInterface
1212
{

GraphQLiteBundle.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
4+
namespace TheCodingMachine\GraphQLite\Bundle;
5+
6+
use TheCodingMachine\GraphQLite\Bundle\DependencyInjection\GraphQLiteExtension;
7+
use TheCodingMachine\GraphQLite\Bundle\DependencyInjection\OverblogGraphiQLEndpointWiringPass;
8+
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
9+
use Symfony\Component\DependencyInjection\ContainerBuilder;
10+
use Symfony\Component\HttpKernel\Bundle\Bundle;
11+
use TheCodingMachine\GraphQLite\Bundle\DependencyInjection\GraphQLiteCompilerPass;
12+
13+
class GraphQLiteBundle extends Bundle
14+
{
15+
public function build(ContainerBuilder $container): void
16+
{
17+
parent::build($container);
18+
19+
$container->addCompilerPass(new GraphQLiteCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION);
20+
$container->addCompilerPass(new OverblogGraphiQLEndpointWiringPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1);
21+
}
22+
23+
public function getContainerExtension()
24+
{
25+
if (null === $this->extension) {
26+
$this->extension = new GraphQLiteExtension();
27+
}
28+
29+
return $this->extension;
30+
}
31+
}

GraphiQL/EndpointResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace TheCodingMachine\Graphqlite\Bundle\GraphiQL;
3+
namespace TheCodingMachine\GraphQLite\Bundle\GraphiQL;
44

55
use Overblog\GraphiQLBundle\Config\GraphiQLControllerEndpoint;
66
use Overblog\GraphiQLBundle\Config\GraphQLEndpoint\GraphQLEndpointInvalidSchemaException;

GraphqliteBundle.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

Mappers/RequestParameter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Graphqlite\Bundle\Mappers;
4+
namespace TheCodingMachine\GraphQLite\Bundle\Mappers;
55

66

77
use GraphQL\Type\Definition\ResolveInfo;
8-
use TheCodingMachine\Graphqlite\Bundle\Context\SymfonyRequestContextInterface;
8+
use TheCodingMachine\GraphQLite\Bundle\Context\SymfonyRequestContextInterface;
99
use TheCodingMachine\GraphQLite\GraphQLRuntimeException as GraphQLException;
1010
use TheCodingMachine\GraphQLite\Parameters\ParameterInterface;
1111

Mappers/RequestParameterMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Graphqlite\Bundle\Mappers;
4+
namespace TheCodingMachine\GraphQLite\Bundle\Mappers;
55

66

77
use phpDocumentor\Reflection\DocBlock;

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Coverage Status](https://coveralls.io/repos/thecodingmachine/graphqlite-bundle/badge.svg?branch=master&service=github)](https://coveralls.io/github/thecodingmachine/graphqlite-bundle?branch=master)
66

77

8-
# Graphqlite bundle
8+
# GraphQLite bundle
99

1010
Symfony 4 bundle for the thecodingmachine/graphqlite package.
1111

0 commit comments

Comments
 (0)