Add container to schema class
carere opened this issue · 1 comments
carere commented
Hello,
Firsts of all, thx for the bundle.
I would like to use the container in order to call some of my services to build the schema class.
I have a service who create on the fly the crud fields for all my entity in AppBundle\Entity.
I would like to call it this way:
<?php
namespace AppBundle\GraphQL;
use AppBundle\GraphQL\Mutation\LoginField;
use AppBundle\GraphQL\Query\ViewerField;
use Youshido\GraphQL\Config\Schema\SchemaConfig;
use Youshido\GraphQL\Schema\AbstractSchema;
class Schema extends AbstractSchema
{
public function build(SchemaConfig $config)
{
$readQueries = $this->container->get('AppBundle\Service\ApiQueryFactory')->getReadQueries();
$queries = array_merge($readQueries, [
new ViewerField()
]);
$crudMutations = $this->container->get('AppBundle\Service\ApiMutationFactory')->getCrudMutations();
$mutations = array_merge($crudMutations, [
new LoginField()
]);
$config->getQuery()->addFields($queries);
$config->getMutation()->addFields($mutations);
}
}
Is someone got any idea ? I just wanna be able to use the container in the Schema class :)
Thx again for the bundle :)
carere commented
My bad, i just need to create the Schema class as a service :)
I close this ;)