Replies: 2 comments 2 replies
-
Hi @mathroc! You are right, the current implementation is far from ideal. We are required to make our providers public and we are fairly limited in term of parameters injection. #[AsAlias('gql.user.something', public: true)]
#[GQL\Provider]
final class UserExtension
{
#[GQL\Query(
targetTypes: 'User',
name: 'something',
resolve: '@=call(service("gql.user.something").something, [value, args["foo"]])',
)]
#[GQL\Arg(name='foo', type: 'Int')]
public function something(User $user, int $foo): int
{
return $this->computeSomething($user->id, $foo);
}
} |
Beta Was this translation helpful? Give feedback.
-
I think we could work from this PR: #728 if we wanted to improve the |
Beta Was this translation helpful? Give feedback.
-
I'm implementing a resolver that add a field to an existing type and I want to access the the
value
of this object type (to get its id and do some sql queries for example)I might have missed it but I couldn't find how to do this easily. I first tried something like this:
hoping that it would get auto-injected, but it's not (I was not really expecting to work, but it would be nice to be able to implement something like that, something à la Symfony
ValueResolverInterface
like discussed in #875 would be nice)next step was to specify the
$resolve
argument of#[GQL\Query]
, and after a few tries I go it working with this:but this means:
resolve:
expression#[GQL\Query]
attribute as the bundle would try to expose them as GraphQL argumentsbut at least it works :)
then I had a case where I want to have the value and a GraphQL argument, so I tried something like this:
but this doesn't work because unpacking with
...
isn't supported in expressions, so[value, ...args]
doesn't work.Is there a better way to do this? I would really like to this with attributes on DTO instead of doing too much stuff "manually" so that everything is less error-prone.
maybe something like this:
wdyt? or again, maybe I've missed something?
thank you,
Beta Was this translation helpful? Give feedback.
All reactions