GraphQLBundle icon indicating copy to clipboard operation
GraphQLBundle copied to clipboard

ResolveInfo not available in Query

Open fp-cfr opened this issue 1 year ago • 8 comments

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Version/Branch 1.1.0

Hello, I'm working on a large project with the update of the lib from version 1.0.0 to version 1.4.0. The following code is used which causes problems with the update:

#[GQL\Query(resolve: "query('CurrentClass:: getUser', info, args.id)")]
#[GQL\Arg('id', 'String!')]
public function getUser(ResolveInfo $info, string $id): User

Error:

Argument n°1 "$resolveInfo" on method "getUser" cannot be auto-guessed from the following type guessers:
[Type Hint] No corresponding GraphQL scalar,enum,input found for class "GraphQL\Type\Definition\ResolveInfo"

Since 1.1.0, is there another way to get ResolveInfo or is the observed behavior a bug?

fp-cfr avatar May 27 '24 13:05 fp-cfr

I am having the same issue @Vincz any suggestion how to get ResolverInfo in Query in versions after 1.1.0?

AlexOstrovsky avatar Jun 03 '24 12:06 AlexOstrovsky

Hi guys. In this case, the argument should be ignored from arguments generation in the MetadataParser and it should be populated automatically by the ArgumentsTransformer.
Any of you want to work on this?

Vincz avatar Jun 03 '24 12:06 Vincz

@Vincz TBO I looked into it a little and was able to skip arg 'info' in guessArgs of MetadataParser but then I don't see any way to know in ArgumentsTransformer if the Query has 'info' argument like in example: public function getUser(ResolveInfo $info, string $id) because generated function don't know about info as we skipped this argument. Would be so kind and ask someone who knows better what to do to look in it? Thanks.

AlexOstrovsky avatar Jun 27 '24 07:06 AlexOstrovsky

Hi @AlexOstrovsky! I'll try to look into it by the end of the week.

Vincz avatar Jun 27 '24 07:06 Vincz

Hi @Vincz any luck with this?

AlexOstrovsky avatar Jul 03 '24 04:07 AlexOstrovsky

@Vincz did you have time to look at this by any chance?

AlexOstrovsky avatar Jul 19 '24 09:07 AlexOstrovsky

Hi @AlexOstrovsky You can find here an implementation: https://github.com/overblog/GraphQLBundle/pull/1191 Let me know what you think

Vincz avatar Aug 08 '24 10:08 Vincz

@Vincz tried your fork all works as expeted from my point of view

AlexOstrovsky avatar Aug 08 '24 10:08 AlexOstrovsky