LastDragon-ru / lara-asp

Awesome Set of Packages for Laravel
MIT License
11 stars 1 forks source link

Impossible to use @searchBy directive with custom FieldResolver directive #65

Closed webard closed 1 year ago

webard commented 1 year ago

Hello,

after upgrading package to v4, in addition with latest version of webonyx/graphql and nuwave/lighthouse, it is impossible to use @searchBy directive with custom resolver directive.

I have @report directive which is very similar to @all directive, but adds some eloquent builder methods.

My schema is:

input CouponFilter {
    id: ID
    name: String
    code: String
    type: String
}

coupons(filter: CouponFilter @searchBy): [Coupon] @all

couponReport(filter: CouponFilter @searchBy): [CouponReport] @report
  1. When I remove filter: CouponFilter @searchBy from couponReport - everything is fine.
  2. When I change @report to @all in couponReport query - everything is fine.
  3. When I change body of @report directive class to be exactly as @all - does not work
  4. When I change CouponReport to Coupon as return type of couponReport query - does not work.

Error is:

 LastDragon_ru\LaraASP\GraphQL\Builder\Exceptions\TypeDefinitionImpossibleToCreateType 

  Definition `LastDragon_ru\LaraASP\GraphQL\SearchBy\Types\Scalar`: Impossible to create type for type `input CouponFilter { id }`.

  at vendor/lastdragon-ru/lara-asp-graphql/src/Builder/Manipulator.php:97
     93▕         // Create new
     94▕         $node = $instance->getTypeDefinitionNode($this, $name, $source);
     95▕ 
     96▕         if (!$node) {
  ➜  97▕             throw new TypeDefinitionImpossibleToCreateType($definition, $source);
     98▕         }
     99▕ 
    100▕         if ($name !== $this->getNodeName($node)) {
    101▕             throw new TypeDefinitionInvalidTypeName($definition, $name, $this->getNodeName($node));

The error must happened with recent changes, because before version 4 I was using dev-master and everything was fine.

Edit:

Probably it is related with commit https://github.com/LastDragon-ru/lara-asp/commit/c3ffa70c2c7f5a676edd022fdfbd04593ccb747e

But that way disables usage of custom resolvers :(

LastDragon-ru commented 1 year ago

Thanks for the report. I've added the fix to the master branch, please see Builder type detection. Let me know please if you have any question or it doesn't work :) (if all fine I will release new version soon).