Skip to content

Update GraphQLite to the 5th version #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions Command/DumpSchemaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace TheCodingMachine\Graphqlite\Bundle\Command;
namespace TheCodingMachine\GraphQLite\Bundle\Command;

use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\TypeWithFields;
use GraphQL\Utils\SchemaPrinter;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -63,15 +63,19 @@ private function sortSchema(): void
{
$config = $this->schema->getConfig();

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

$fields = $config->query->getFields();
ksort($fields);
$refl->setValue($config->query, $fields);
if ($config->query) {
$fields = $config->query->getFields();
ksort($fields);
$refl->setValue($config->query, $fields);
}

$fields = $config->mutation->getFields();
ksort($fields);
$refl->setValue($config->mutation, $fields);
if ($config->mutation) {
$fields = $config->mutation->getFields();
ksort($fields);
$refl->setValue($config->mutation, $fields);
}
}
}
2 changes: 1 addition & 1 deletion Context/SymfonyGraphQLContext.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


namespace TheCodingMachine\Graphqlite\Bundle\Context;
namespace TheCodingMachine\GraphQLite\Bundle\Context;


use Symfony\Component\HttpFoundation\Request;
Expand Down
4 changes: 2 additions & 2 deletions Context/SymfonyRequestContextInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TheCodingMachine\Graphqlite\Bundle\Context;
namespace TheCodingMachine\GraphQLite\Bundle\Context;

use Symfony\Component\HttpFoundation\Request;

Expand All @@ -10,4 +10,4 @@ interface SymfonyRequestContextInterface
* @return Request
*/
public function getRequest(): Request;
}
}
2 changes: 1 addition & 1 deletion Controller/GraphQL/InvalidUserPasswordException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


namespace TheCodingMachine\Graphqlite\Bundle\Controller\GraphQL;
namespace TheCodingMachine\GraphQLite\Bundle\Controller\GraphQL;

use Exception;
use TheCodingMachine\GraphQLite\Exceptions\GraphQLException;
Expand Down
3 changes: 1 addition & 2 deletions Controller/GraphQL/LoginController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace TheCodingMachine\Graphqlite\Bundle\Controller\GraphQL;
namespace TheCodingMachine\GraphQLite\Bundle\Controller\GraphQL;


use Symfony\Component\EventDispatcher\EventDispatcherInterface;
Expand All @@ -13,7 +13,6 @@
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use TheCodingMachine\GraphQLite\Annotations\Mutation;
use TheCodingMachine\GraphQLite\Annotations\Query;

class LoginController
{
Expand Down
12 changes: 1 addition & 11 deletions Controller/GraphQL/MeController.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
<?php
namespace TheCodingMachine\Graphqlite\Bundle\Controller\GraphQL;
namespace TheCodingMachine\GraphQLite\Bundle\Controller\GraphQL;


use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use TheCodingMachine\GraphQLite\Annotations\Mutation;
use TheCodingMachine\GraphQLite\Annotations\Query;
use TheCodingMachine\Graphqlite\Bundle\Types\BasicUser;

class MeController
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


namespace TheCodingMachine\Graphqlite\Bundle\Controller;
namespace TheCodingMachine\GraphQLite\Bundle\Controller;


use Laminas\Diactoros\ResponseFactory;
Expand All @@ -11,9 +11,7 @@
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
use TheCodingMachine\GraphQLite\Http\HttpCodeDecider;
use function array_map;
use GraphQL\Error\Debug;
use GraphQL\Executor\ExecutionResult;
use GraphQL\Executor\Promise\Promise;
use GraphQL\Server\ServerConfig;
use GraphQL\Server\StandardServer;
use GraphQL\Upload\UploadMiddleware;
Expand All @@ -27,18 +25,18 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use TheCodingMachine\Graphqlite\Bundle\Context\SymfonyGraphQLContext;
use TheCodingMachine\GraphQLite\Bundle\Context\SymfonyGraphQLContext;

/**
* Listens to every single request and forward Graphql requests to Graphql Webonix standardServer.
*/
class GraphqliteController
class GraphQLiteController
{
/**
* @var HttpMessageFactoryInterface
*/
private $httpMessageFactory;
/** @var bool|int */
/** @var int */
private $debug;
/**
* @var ServerConfig
Expand All @@ -49,7 +47,7 @@ public function __construct(ServerConfig $serverConfig, HttpMessageFactoryInterf
{
$this->serverConfig = $serverConfig;
$this->httpMessageFactory = $httpMessageFactory ?: new PsrHttpFactory(new ServerRequestFactory(), new StreamFactory(), new UploadedFileFactory(), new ResponseFactory());
$this->debug = $debug ?? $serverConfig->getDebug();
$this->debug = $debug ?? $serverConfig->getDebugFlag();
}

public function loadRoutes(): RouteCollection
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


namespace TheCodingMachine\Graphqlite\Bundle\DependencyInjection;
namespace TheCodingMachine\GraphQLite\Bundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


namespace TheCodingMachine\Graphqlite\Bundle\DependencyInjection;
namespace TheCodingMachine\GraphQLite\Bundle\DependencyInjection;

use Doctrine\Common\Annotations\PsrCachedReader;
use GraphQL\Server\ServerConfig;
Expand Down Expand Up @@ -47,17 +47,17 @@
use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Mutation;
use TheCodingMachine\GraphQLite\Annotations\Query;
use TheCodingMachine\Graphqlite\Bundle\Controller\GraphQL\LoginController;
use TheCodingMachine\Graphqlite\Bundle\Controller\GraphQL\MeController;
use TheCodingMachine\GraphQLite\Bundle\Controller\GraphQL\LoginController;
use TheCodingMachine\GraphQLite\Bundle\Controller\GraphQL\MeController;
use TheCodingMachine\GraphQLite\GraphQLRuntimeException as GraphQLException;
use TheCodingMachine\GraphQLite\Mappers\StaticTypeMapper;
use TheCodingMachine\GraphQLite\SchemaFactory;
use TheCodingMachine\Graphqlite\Bundle\Types\SymfonyUserInterfaceType;
use TheCodingMachine\GraphQLite\Bundle\Types\SymfonyUserInterfaceType;

/**
* Detects controllers and types automatically and tag them.
*/
class GraphqliteCompilerPass implements CompilerPassInterface
class GraphQLiteCompilerPass implements CompilerPassInterface
{
/**
* @var AnnotationReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
<?php


namespace TheCodingMachine\Graphqlite\Bundle\DependencyInjection;
namespace TheCodingMachine\GraphQLite\Bundle\DependencyInjection;


use GraphQL\Error\DebugFlag;
use TheCodingMachine\GraphQLite\Mappers\Root\RootTypeMapperFactoryInterface;
use function array_map;
use GraphQL\Error\Debug;
use GraphQL\Server\ServerConfig;
use GraphQL\Type\Definition\ObjectType;
use function implode;
use function is_dir;
use Mouf\Composer\ClassNameMapper;
use function rtrim;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use TheCodingMachine\GraphQLite\GraphQLRuntimeException as GraphQLException;
use function var_dump;

class GraphqliteExtension extends Extension
class GraphQLiteExtension extends Extension
{

public function getAlias()
{
return 'graphqlite';
}

/**
* Loads a specific configuration.
*
Expand Down Expand Up @@ -84,9 +83,9 @@ function($namespace): string {
if (isset($config['debug'])) {
$debugCode = $this->toDebugCode($config['debug']);
} else {
$debugCode = Debug::RETHROW_UNSAFE_EXCEPTIONS;
$debugCode = DebugFlag::RETHROW_UNSAFE_EXCEPTIONS;
}
$definition->addMethodCall('setDebug', [$debugCode]);
$definition->addMethodCall('setDebugFlag', [$debugCode]);

$container->registerForAutoconfiguration(ObjectType::class)
->addTag('graphql.output_type');
Expand All @@ -101,10 +100,10 @@ function($namespace): string {
private function toDebugCode(array $debug): int
{
$code = 0;
$code |= ($debug['INCLUDE_DEBUG_MESSAGE'] ?? 0)*Debug::INCLUDE_DEBUG_MESSAGE;
$code |= ($debug['INCLUDE_TRACE'] ?? 0)*Debug::INCLUDE_TRACE;
$code |= ($debug['RETHROW_INTERNAL_EXCEPTIONS'] ?? 0)*Debug::RETHROW_INTERNAL_EXCEPTIONS;
$code |= ($debug['RETHROW_UNSAFE_EXCEPTIONS'] ?? 0)*Debug::RETHROW_UNSAFE_EXCEPTIONS;
$code |= ($debug['INCLUDE_DEBUG_MESSAGE'] ?? 0)*DebugFlag::INCLUDE_DEBUG_MESSAGE;
$code |= ($debug['INCLUDE_TRACE'] ?? 0)*DebugFlag::INCLUDE_TRACE;
$code |= ($debug['RETHROW_INTERNAL_EXCEPTIONS'] ?? 0)*DebugFlag::RETHROW_INTERNAL_EXCEPTIONS;
$code |= ($debug['RETHROW_UNSAFE_EXCEPTIONS'] ?? 0)*DebugFlag::RETHROW_UNSAFE_EXCEPTIONS;
return $code;
}
}
4 changes: 2 additions & 2 deletions DependencyInjection/OverblogGraphiQLEndpointWiringPass.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace TheCodingMachine\Graphqlite\Bundle\DependencyInjection;
namespace TheCodingMachine\GraphQLite\Bundle\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use TheCodingMachine\Graphqlite\Bundle\GraphiQL\EndpointResolver;
use TheCodingMachine\GraphQLite\Bundle\GraphiQL\EndpointResolver;

final class OverblogGraphiQLEndpointWiringPass implements CompilerPassInterface
{
Expand Down
31 changes: 31 additions & 0 deletions GraphQLiteBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php


namespace TheCodingMachine\GraphQLite\Bundle;

use TheCodingMachine\GraphQLite\Bundle\DependencyInjection\GraphQLiteExtension;
use TheCodingMachine\GraphQLite\Bundle\DependencyInjection\OverblogGraphiQLEndpointWiringPass;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use TheCodingMachine\GraphQLite\Bundle\DependencyInjection\GraphQLiteCompilerPass;

class GraphQLiteBundle extends Bundle
{
public function build(ContainerBuilder $container): void
{
parent::build($container);

$container->addCompilerPass(new GraphQLiteCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION);
$container->addCompilerPass(new OverblogGraphiQLEndpointWiringPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1);
}

public function getContainerExtension()
{
if (null === $this->extension) {
$this->extension = new GraphQLiteExtension();
}

return $this->extension;
}
}
2 changes: 1 addition & 1 deletion GraphiQL/EndpointResolver.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TheCodingMachine\Graphqlite\Bundle\GraphiQL;
namespace TheCodingMachine\GraphQLite\Bundle\GraphiQL;

use Overblog\GraphiQLBundle\Config\GraphiQLControllerEndpoint;
use Overblog\GraphiQLBundle\Config\GraphQLEndpoint\GraphQLEndpointInvalidSchemaException;
Expand Down
21 changes: 0 additions & 21 deletions GraphqliteBundle.php

This file was deleted.

4 changes: 2 additions & 2 deletions Mappers/RequestParameter.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php


namespace TheCodingMachine\Graphqlite\Bundle\Mappers;
namespace TheCodingMachine\GraphQLite\Bundle\Mappers;


use GraphQL\Type\Definition\ResolveInfo;
use TheCodingMachine\Graphqlite\Bundle\Context\SymfonyRequestContextInterface;
use TheCodingMachine\GraphQLite\Bundle\Context\SymfonyRequestContextInterface;
use TheCodingMachine\GraphQLite\GraphQLRuntimeException as GraphQLException;
use TheCodingMachine\GraphQLite\Parameters\ParameterInterface;

Expand Down
2 changes: 1 addition & 1 deletion Mappers/RequestParameterMiddleware.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


namespace TheCodingMachine\Graphqlite\Bundle\Mappers;
namespace TheCodingMachine\GraphQLite\Bundle\Mappers;


use phpDocumentor\Reflection\DocBlock;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Coverage Status](https://coveralls.io/repos/thecodingmachine/graphqlite-bundle/badge.svg?branch=master&service=github)](https://coveralls.io/github/thecodingmachine/graphqlite-bundle?branch=master)


# Graphqlite bundle
# GraphQLite bundle

Symfony 4 bundle for the thecodingmachine/graphqlite package.

Expand Down
Loading