Skip to content
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

"Use your beans as input types" doesn't work on Symfony #148

Closed
ThibBal opened this issue Oct 9, 2019 · 1 comment · Fixed by #204
Closed

"Use your beans as input types" doesn't work on Symfony #148

ThibBal opened this issue Oct 9, 2019 · 1 comment · Fixed by #204

Comments

@ThibBal
Copy link
Contributor

ThibBal commented Oct 9, 2019

Stack: Symfony 4 - TDBM5 - GraphQLite

Situation: I have an AdminUser bean, an AdminUserDAO (with the Factory annotation). I want to inject into my mutation the AdminUser automatically.

public function saveAdmin(?AdminUser $adminUser, string $lastname, string $firstname, string $email, ?string $login, ?string $phone, ?string $password, string $status, string $role, string $pole): AdminUser

Error : I have an error :

In DefinitionErrorExceptionPass.php line 54:

Cannot autowire service "App\Model\AdminUser": argument "$email" of method "App\Model\Generated\AbstractAdminUser::
__construct()" is type-hinted "string", you should configure its value explicitly.

@moufmouf
Copy link
Member

After looking at the problem, the issue is linked to Symfony's argument autowiring.

If your GraphQL controller class is tagged with "controller.service_arguments", Symfony will try to autowire the argument automatically (even if it is not annotated with @autowire).

The "controller.service_arguments" tag is put on any class that:

  • is part of "App\Controller" directory
  • OR extends the AbstractController class

We need to fix the documentation and the GraphQLite Symfony bundle to be sure that the default values we propose for the GraphQL controllers are NOT in App\Controller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants