Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Internal server error" when client send invalid query with unknown type #2185

Closed
LastDragon-ru opened this issue Jul 25, 2022 · 4 comments
Closed
Labels
6.x Related to the 6.x release series bug An error within Lighthouse

Comments

@LastDragon-ru
Copy link
Contributor

LastDragon-ru commented Jul 25, 2022

Describe the bug / Expected behavior/Solution

Not sure this is lighthouse or graphql-php bug. But this is definitely not a server error so the Client should see the message about invalid query (eg "Unknown Type is not a valid/known type").

Steps to reproduce

  1. Install laravel
  2. Set APP_DEBUG=false
  3. composer require nuwave/lighthouse
  4. Use following schema
    type Query {
        users: [User!]! @all
    }
     
    type User {
        id: ID!
    }
  5. php artisan serve
  6. curl -g -X POST -H "Content-Type: application/json" -d '{"query":"query($unknown: UnknownType){users{id}}"}' http://127.0.0.1:8000/graphql

Output/Logs

{"errors":[{"message":"Internal server error","extensions":{"category":"schema"}}]}

So the client will never know what is wrong

Click to expand
[2022-07-25 12:52:58] local.ERROR: Failed to load type: UnknownType. Make sure the type is present in your schema definition. {"exception":"[object] (Nuwave\\Lighthouse\\Exceptions\\DefinitionException(code: 0): Failed to load type: UnknownType. Make sure the type is present in your schema definition. at vendor/nuwave/lighthouse/src/Schema/TypeRegistry.php:93)
[stacktrace]
#0 vendor/nuwave/lighthouse/src/Schema/TypeRegistry.php(126): Nuwave\\Lighthouse\\Schema\\TypeRegistry::failedToLoadType()
#1 vendor/nuwave/lighthouse/src/Schema/SchemaBuilder.php(78): Nuwave\\Lighthouse\\Schema\\TypeRegistry->get()
#2 vendor/webonyx/graphql-php/src/Type/Schema.php(350): Nuwave\\Lighthouse\\Schema\\SchemaBuilder->Nuwave\\Lighthouse\\Schema\\{closure}()
#3 vendor/webonyx/graphql-php/src/Type/Schema.php(326): GraphQL\\Type\\Schema->loadType()
#4 vendor/webonyx/graphql-php/src/Utils/AST.php(580): GraphQL\\Type\\Schema->getType()
#5 vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(436): GraphQL\\Utils\\AST::typeFromAST()
#6 vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(322): GraphQL\\Utils\\TypeInfo::typeFromAST()
#7 vendor/webonyx/graphql-php/src/Language/Visitor.php(466): GraphQL\\Utils\\TypeInfo->enter()
#8 vendor/webonyx/graphql-php/src/Language/Visitor.php(277): GraphQL\\Language\\Visitor::GraphQL\\Language\\{closure}()
#9 vendor/webonyx/graphql-php/src/Validator/DocumentValidator.php(224): GraphQL\\Language\\Visitor::visit()
#10 vendor/webonyx/graphql-php/src/Validator/DocumentValidator.php(116): GraphQL\\Validator\\DocumentValidator::visitUsingRules()
#11 vendor/webonyx/graphql-php/src/GraphQL.php(153): GraphQL\\Validator\\DocumentValidator::validate()
#12 vendor/webonyx/graphql-php/src/GraphQL.php(94): GraphQL\\GraphQL::promiseToExecute()
#13 vendor/nuwave/lighthouse/src/GraphQL.php(268): GraphQL\\GraphQL::executeQuery()
#14 vendor/nuwave/lighthouse/src/GraphQL.php(203): Nuwave\\Lighthouse\\GraphQL->executeParsedQuery()
#15 vendor/nuwave/lighthouse/src/GraphQL.php(162): Nuwave\\Lighthouse\\GraphQL->parseAndExecuteQuery()
#16 vendor/nuwave/lighthouse/src/GraphQL.php(121): Nuwave\\Lighthouse\\GraphQL->executeOperation()
#17 vendor/nuwave/lighthouse/src/Support/Utils.php(99): Nuwave\\Lighthouse\\GraphQL->Nuwave\\Lighthouse\\{closure}()
#18 vendor/nuwave/lighthouse/src/GraphQL.php(120): Nuwave\\Lighthouse\\Support\\Utils::mapEach()
#19 vendor/nuwave/lighthouse/src/Support/Http/Controllers/GraphQLController.php(32): Nuwave\\Lighthouse\\GraphQL->executeOperationOrOperations()
#20 vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(48): Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController->__invoke()
#21 vendor/laravel/framework/src/Illuminate/Routing/Route.php(261): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#22 vendor/laravel/framework/src/Illuminate/Routing/Route.php(204): Illuminate\\Routing\\Route->runController()
#23 vendor/laravel/framework/src/Illuminate/Routing/Router.php(725): Illuminate\\Routing\\Route->run()
#24 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#25 vendor/nuwave/lighthouse/src/Support/Http/Middleware/AttemptAuthentication.php(34): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#26 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Nuwave\\Lighthouse\\Support\\Http\\Middleware\\AttemptAuthentication->handle()
#27 vendor/nuwave/lighthouse/src/Support/Http/Middleware/AcceptJson.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#28 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Nuwave\\Lighthouse\\Support\\Http\\Middleware\\AcceptJson->handle()
#29 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#30 vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\\Pipeline\\Pipeline->then()
#31 vendor/laravel/framework/src/Illuminate/Routing/Router.php(703): Illuminate\\Routing\\Router->runRouteWithinStack()
#32 vendor/laravel/framework/src/Illuminate/Routing/Router.php(667): Illuminate\\Routing\\Router->runRoute()
#33 vendor/laravel/framework/src/Illuminate/Routing/Router.php(656): Illuminate\\Routing\\Router->dispatchToRoute()
#34 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\\Routing\\Router->dispatch()
#35 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#36 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#37 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#38 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#39 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#40 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#41 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#42 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#43 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#44 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#45 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#46 vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#47 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\HandleCors->handle()
#48 vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#49 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#50 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#51 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\\Pipeline\\Pipeline->then()
#52 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#53 public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle()
#54 vendor/laravel/framework/src/Illuminate/Foundation/resources/server.php(16): require_once('...')
#55 {main}
"} 

Lighthouse Version

v5.57.0

@spawnia
Copy link
Collaborator

spawnia commented Jul 25, 2022

The fix for this depends on webonyx/graphql-php#1068 which will be available in graphql-php 15. If you are brave, you can try running #1898 - it will be available in Lighthouse v6.

@spawnia spawnia added bug An error within Lighthouse 6.x Related to the 6.x release series labels Jul 25, 2022
@videni
Copy link

videni commented Jan 12, 2023

@spawnia Could you make that fix available on version ^5 please? currently, we are not able to upgrade to Laravel 8, we are still using Laravel 6.

@spawnia
Copy link
Collaborator

spawnia commented Jan 12, 2023

@videni no, it is too complicated and involves subtle breaking changes.

@spawnia
Copy link
Collaborator

spawnia commented Feb 17, 2023

This is fixed in master right now and will be released when v6 is ready.

@spawnia spawnia closed this as completed Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.x Related to the 6.x release series bug An error within Lighthouse
Projects
None yet
Development

No branches or pull requests

3 participants