Skip to content

While reporting error to Laravel's ExceptionHandler::handle, doesn't satisfy the Exception type #1491

@ssi-anik

Description

@ssi-anik

Laravel Version: 6.18.25
Lighthouse version: ^4.15
PHP version: 7.4.7

Laravel configuration: Default configuration
Lighthouse configuration: Default configuration

I created my own mutation resolver, and I used the arguments to my function like $rootValue, array $args, GraphQLContext $context = null, ResolveInfo $resolveInfo. I forgot to import the ResolveInfo class. Thus, the compiler thought the class resides in App\GraphQL\Mutations namespace. Which it doesn't.

So, when I executed the mutation, it showed the error like below.
Screen Shot 2020-07-18 at 2 32 51 PM

I ran dd(get_class($error), class_implements($error), get_class($error->getPrevious()), class_implements($error->getPrevious())); in Nuwave\Lighthouse\Execution\ReportingErrorHandler::20 and found

Screen Shot 2020-07-18 at 2 26 14 PM

So, I changed $error->getPrevious() to $error in Nuwave\Lighthouse\Execution\ReportingErrorHandler::25 and found the following which I think should be the actual behavior.
Screen Shot 2020-07-18 at 2 37 13 PM


  • In my server,
type Mutation {
    jwtLogin(input: LoginInput @spread): AuthPayload! @field(resolver: "AuthMutation@jwtLogin")
}
  • In my mutation
<?php

namespace App\GraphQL\Mutations;

use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;

class AuthMutation 
{
    public function jwtLogin ($rootValue, array $args, GraphQLContext $context = null, ResolveInfo $resolveInfo) {
        // login goes here
    }
}
  • In my client
mutation {
  jwtLogin(input: {
    username:"admin@example.com"
    password: "12345"
  }) {
    access_token
    refresh_token
    expires_in
    token_type
    user{
      id
      name
      email
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions