youshido-php / GraphQLBundle

Pure PHP implementation of GraphQL Server – Symfony Bundle
MIT License
284 stars 44 forks source link

Not able to inject a custom schema service #47

Closed mloureiro closed 6 years ago

mloureiro commented 7 years ago

tl;dr

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

PR: https://github.com/Youshido/GraphQLBundle/pull/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

iainmckay commented 7 years ago

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

viniychuk commented 6 years ago

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