Describe the bug
When lighthouse is installed, the command artisan route:list no longer works due to a typehint that isn't fulfilled.
Expected behavior
artisan route:list should output the list of registered routes
Output/Logs
/www # php artisan route:list
In ExtensionRequest.php line 20:
Argument 2 passed to Nuwave\Lighthouse\Schema\Extensions\ExtensionRequest::__construct() must be of the type string
, null given, called in /www/vendor/nuwave/lighthouse/src/Support/Http/Controllers/GraphQLController.php on line 41
Environment
Lighthouse Version: dev-master
Laravel Version: 5.7.6
PHP Version: 7.2.10
It's because in GraphQLController#35, the query input is null. So maybe it has to have a default value or check that is not null (or move this logic to another part).
@Jigsaw5279 @enzonotario Just ran into this myself w/ batched queries which opens up an additional can of worms but I'm working on a PR. I'll reference this issue when I have it ready to go. Thanks for reporting!!
@Jigsaw5279 @enzonotario Just merged in #379. Pull down the latest from master and let me know if that resolves your issue!
@chrissm79 I get another error on GraphQLController#38
Symfony\Component\Debug\Exception\FatalThrowableError : Call to a member function parameters() on null
at /home/enzo/Code/backend/vendor/laravel/framework/src/Illuminate/Http/Request.php:625
621| public function offsetExists($offset)
622| {
623| return array_key_exists(
624| $offset,
> 625| $this->all() + $this->route()->parameters()
626| );
627| }
628|
629| /**
Exception trace:
1 Illuminate\Http\Request::offsetExists()
/home/enzo/Code/backend/vendor/nuwave/lighthouse/src/Support/Http/Controllers/GraphQLController.php:38
2 Nuwave\Lighthouse\Support\Http\Controllers\GraphQLController::__construct(Object(Illuminate\Http\Request), Object(Nuwave\Lighthouse\Schema\Extensions\ExtensionRegistry), Object(Nuwave\Lighthouse\Schema\MiddlewareRegistry), Object(Nuwave\Lighthouse\GraphQL))
[internal]:0
since $request->route() is null.
I don't know what is batched for, but with:
$this->batched = $request->route() === null && config('lighthouse.batched_queries', true);
all my tests passes and can do php artisan route:list (but maybe it breaks the batched funcionality)
@enzonotario I got the latest changes pulled into my project as well so I was able to resolve the issue w/ #382. Will merge it after I pull in #284
@enzonotario merged in the hotfix, I'm able to run the php artisan route:list command for my project successfully but let me know if you're still running into any problems!
@chrissm79 yes it works! thanks so much!
Most helpful comment
@enzonotario I got the latest changes pulled into my project as well so I was able to resolve the issue w/ #382. Will merge it after I pull in #284