-
Notifications
You must be signed in to change notification settings - Fork 222
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
Container inlining issue #1103
Comments
Hi @rusted-love App\GraphQL\TestProvider:
public: true Also, your providers don't need to extend |
But why library does not provide some kind if compiled container? |
I guess we could. I'll look into it when I'll have a bit of time. |
Hi! I had a quick look at this, in a very simple playground project, I have this generated type: <?php
namespace GraphQL\AutoGeneratedDefinitions;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use Overblog\GraphQLBundle\Definition\ConfigProcessor;
use Overblog\GraphQLBundle\Definition\GraphQLServices;
use Overblog\GraphQLBundle\Definition\Resolver\AliasedInterface;
use Overblog\GraphQLBundle\Definition\Type\GeneratedTypeInterface;
/**
* THIS FILE WAS GENERATED AND SHOULD NOT BE EDITED MANUALLY.
*/
final class QueryType extends ObjectType implements GeneratedTypeInterface, AliasedInterface
{
public const NAME = 'Query';
public function __construct(ConfigProcessor $configProcessor, GraphQLServices $services)
{
$config = [
'name' => self::NAME,
'fields' => fn() => [
'hello' => [
'type' => Type::nonNull(Type::string()),
'resolve' => function ($value, $args, $context, $info) use ($services) {
return $services->get('container')->get("App\\Query\\Hello")->hello(...$services->get('container')->get('overblog_graphql.arguments_transformer')->getArguments(["name" => "String"], $args, $info));
},
'args' => [
[
'name' => 'name',
'type' => Type::string(),
'defaultValue' => 'World',
],
],
],
],
];
parent::__construct($configProcessor->process($config));
}
/**
* {@inheritdoc}
*/
public static function getAliases(): array
{
return [self::NAME];
}
} I think the quickest way to solve this issue would be to register the GraphQL services into the But maybe we can go one step further and generate something like this instead: <?php
namespace GraphQL\AutoGeneratedDefinitions;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use Overblog\GraphQLBundle\Definition\ConfigProcessor;
use Overblog\GraphQLBundle\Definition\GraphQLServices;
use Overblog\GraphQLBundle\Definition\Resolver\AliasedInterface;
use Overblog\GraphQLBundle\Definition\Type\GeneratedTypeInterface;
/**
* THIS FILE WAS GENERATED AND SHOULD NOT BE EDITED MANUALLY.
*/
final class QueryType extends ObjectType implements GeneratedTypeInterface, AliasedInterface
{
public const NAME = 'Query';
public function __construct(
ConfigProcessor $configProcessor,
App\Query\Hello $service0,
ArgumentsTransformer $argumentTransformer,
) {
$config = [
'name' => self::NAME,
'fields' => fn() => [
'hello' => [
'type' => Type::nonNull(Type::string()),
'resolve' => static fn ($value, $args, $context, $info)
=> $service0->hello(...$argumentTransformer->getArguments(["name" => "String"], $args, $info)),
'args' => [
[
'name' => 'name',
'type' => Type::string(),
'defaultValue' => 'World',
],
],
],
],
];
parent::__construct($configProcessor->process($config));
}
/**
* {@inheritdoc}
*/
public static function getAliases(): array
{
return [self::NAME];
}
} It should let the SymfonyContainer do more optimization at compile time and improve performances a bit. wdyt? Depending on how much work this represents, I can take a look at it in the next weeks |
Consider following example
Issue is I'm getting error that says
The "App\GraphQL\TestProvider" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
Resolver in RootQueryType in
cache
directory looks like following:RootQuery looks like this.
Any suggestion how to make it work?
The text was updated successfully, but these errors were encountered: