You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there,
thanks for the best graphql implementation available! I have one problem to report:
I want to have mutations with optional parameters. With String and Int it is working fine. But with a custom input type, e.g. User, it does not work. Here is an example of my mutation:
/**
* @Mutation()
* @param User $user
* @return string
*/
public function doSomething(?User $user = null): string
{
if (null !== $user) {
return "no user";
}
return "user";
}
Then I have a factory:
/**
* @Factory()
*/
public function getUserById(int $id): User
{
return $this->userManager->findOneById($id);
}
But that means that I have to replicate all the mutations that work with or without custom input types. I wished it would be possible to do this for calling the mutation with user = null:
It makes sense, since the Factoy method has a mandatory integer as param. I tried to make this optional and return ?User. But this is not allowed. I then tried to throw an exception but this bubbles to the frontend.
Am I missing something? My workaround now is to use an integer as param and if it is not null get the user by hand – omitting the factory. But it does not feel good.
The text was updated successfully, but these errors were encountered:
Hey there,
thanks for the best graphql implementation available! I have one problem to report:
I want to have mutations with optional parameters. With String and Int it is working fine. But with a custom input type, e.g. User, it does not work. Here is an example of my mutation:
Then I have a factory:
It works fine, when I write two mutations:
and
But that means that I have to replicate all the mutations that work with or without custom input types. I wished it would be possible to do this for calling the mutation with user = null:
But then I get this response:
It makes sense, since the Factoy method has a mandatory integer as param. I tried to make this optional and return ?User. But this is not allowed. I then tried to throw an exception but this bubbles to the frontend.
Am I missing something? My workaround now is to use an integer as param and if it is not null get the user by hand – omitting the factory. But it does not feel good.
The text was updated successfully, but these errors were encountered: