-
Notifications
You must be signed in to change notification settings - Fork 222
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
[Documentation] How to organize resolvers with resolver map #433
Comments
Can you try using callable resolver with |
@mcg-web You mean using tagged resolver services instead of the ResolverMap? Like the following? class Greetings implements ResolverInterface
{
public function __invoke(ResolveInfo $info, $name)
{
if($info->fieldName === 'hello'){
return sprintf('hello %s!!!', $name);
}
else if($info->fieldName === 'goodbye'){
return sprintf('goodbye %s!!!', $name);
}
else{
throw new \DomainException('Unknown greetings');
}
}
} |
@mcg-web Same issue for me, could someone show better example how resolver und map? |
@riroxumigu this could maybe help you. I'll try to work on a resolver map using tagged "classic resolver" in the coming days. |
@mcg-web thank You! Thats helped but now I can't execute mutation method to update entity. I did eveyrthing like this https://github.com/overblog/GraphQLBundle/blob/master/docs/definitions/graphql-schema-language.md#define-mutations and class PostMutation which implements MutationInterface. |
@mcg-web any news? |
I really struggle with the Resolver map and how I should organize things.
I'd like to abstract some of the work to reduce verbosity.
My goal is to obtain something as straightforward as the following:
But because of the way the resolver map works, I can't figure out how to implement it this way.
Note that the following works:
But it's clearly very verbose and would become a pain to maintain on a large project!
I could move the
User
field map inside the UserResolver class, but still, it's too much verbosity.Also tried some naive approaches like the following:
And then having
UserResolver
extendingAbstractTypeResolver
but it doesn't seem right.In the end I just want to avoid having to repeat that a million time:
And factor this logic somewhere hidden.
Any thoughts or recommendations?
The text was updated successfully, but these errors were encountered: