youshido-php/GraphQLBundle

Not able to inject a custom schema service

mloureiro opened this issue · 2 comments

tl;dr

Can't Change or initialize the graphql.schema service even through compiler pass.

PR: #48

Hi

First of all, thanks for all the work in GraphQL and GraphQLBundle.

I'm currently trying to inject the Fields into the Schema.
So for that, I can't simply rely on the config graphql.schema_class since the initialization is also needed.
Because of that I've attempted to override the graphql.schema service, and due to the way Symfony works, when there is a duplicated service it ignores/picks one, so since the service is already defined in this services.xml so a compiler pass is needed.

Then I've tried simply to make a compiler pass with:

$container->set('graphql.schema', $container->get('acme.graphql.schema'));

Although even if the service is initialized, there is a class check that will fail since the service is initialized without the class name and initializes the class anyway

Bonus, even if we define the service, we MUST define the schema class which is not relevant.

I am not a Symfony expert, if I'm missing or doing something wrong please tell me.

I'll make a PR for this issue

We've run in to this particular recently as well. Could the PR be reviewed?

Got it in the queue. We will merge it asap.