GraphQLBundle icon indicating copy to clipboard operation
GraphQLBundle copied to clipboard

Injection of `ResolveInfo` into auto-guessed & arguments transformer

Open Vincz opened this issue 5 years ago • 2 comments

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Documented? yes
License MIT

This PR adds a way to inject the ResolveInfo through the Argument Transformers and will be able to auto-guessed it based on the class GraphQL\Type\Definition\ResolveInfo.

Usage example with auto-guessing:

/**
 * @GQL\Type
 */
class MyType {
    /**
     * @GQL\Field(type="[String]!")
     */
    public function getSomething(int $amount, ResolveInfo $info) {
        ...
    }
}

Usage example with @Arg

/**
 * @GQL\Type
 */
class RootQuery {
    /**
     * @GQL\Field(
     *   type="[User]",
     *   args={
     *     @GQL\Arg(name="ids", type="[Int]"),
     *     @GQL\Arg(name="info", type="@info")
     *   },
     *   resolve="@=call(service('UserRepository').getUser, arguments({ids: '[Int]', info: '@info'}, arg))"
     * )
     */
    public $getUsers;
}


Vincz avatar Aug 13 '20 11:08 Vincz

hi Vinc with the Resolver definition enhancement #708 this PR could be totally obsolete since the way how resolver works has been completely rewritten to be more like a Symfony Controller. Can we wait until before merging this? So we can make annotations takes benefit of this new feature.

mcg-web avatar Aug 13 '20 12:08 mcg-web

hi Vinc with the Resolver definition enhancement #708 this PR could be totally obsolete since the way how resolver works has been completely rewritten to be more like a Symfony Controller. Can we wait until before merging this? So we can make annotations takes benefit of this new feature.

Yes, you are right, I forgot about it. No problem, we will merge it later only if it is still relevant. I was also about to work on a way to extend the auto-guessing (to manage case like : https://github.com/overblog/GraphQLBundle/issues/694), but it's the same and will probably not be relevant after the resolver refactoring.

Vincz avatar Aug 13 '20 13:08 Vincz