When trying to execute lighthouse:validate-schema artisan commmand i am getting this error.
Nuwave\Lighthouse\Exceptions\DefinitionException : No matching subclass of GraphQL\Type\Definition\ScalarType of found for the scalar Mixed.
This hasnt ever come up yet and ive been using lighthouse extensively.
I have removed all the contents of my schema.graphql file so it is now a blank file but it is still showing this message.
Expected behavior/Solution
I would execpt the schema to be valid
Steps to reproduce
Output/Logs
{
"message": "No matching subclass of GraphQL\\Type\\Definition\\ScalarType of found for the scalar Mixed",
"exception": "Nuwave\\Lighthouse\\Exceptions\\DefinitionException",
"file": "/home/richard/Projects/snaptuity-api/vendor/nuwave/lighthouse/src/Schema/TypeRegistry.php",
"line": 263,
"trace": [
{
"file": "/home/richard/Projects/snaptuity-api/vendor/nuwave/lighthouse/src/Schema/TypeRegistry.php",
"line": 194,
"function": "resolveScalarType",
"class": "Nuwave\\Lighthouse\\Schema\\TypeRegistry",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/nuwave/lighthouse/src/Schema/TypeRegistry.php",
"line": 176,
"function": "resolveType",
"class": "Nuwave\\Lighthouse\\Schema\\TypeRegistry",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 130,
"function": "Nuwave\\Lighthouse\\Schema\\{closure}",
"class": "Nuwave\\Lighthouse\\Schema\\TypeRegistry",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 105,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/nuwave/lighthouse/src/Schema/TypeRegistry.php",
"line": 177,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/nuwave/lighthouse/src/Schema/TypeRegistry.php",
"line": 147,
"function": "handle",
"class": "Nuwave\\Lighthouse\\Schema\\TypeRegistry",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/webonyx/graphql-php/src/Type/Schema.php",
"line": 164,
"function": "possibleTypes",
"class": "Nuwave\\Lighthouse\\Schema\\TypeRegistry",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/webonyx/graphql-php/src/Type/Schema.php",
"line": 133,
"function": "resolveAdditionalTypes",
"class": "GraphQL\\Type\\Schema",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/nuwave/lighthouse/src/Schema/SchemaBuilder.php",
"line": 91,
"function": "__construct",
"class": "GraphQL\\Type\\Schema",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/nuwave/lighthouse/src/GraphQL.php",
"line": 224,
"function": "build",
"class": "Nuwave\\Lighthouse\\Schema\\SchemaBuilder",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/nuwave/lighthouse/src/GraphQL.php",
"line": 157,
"function": "prepSchema",
"class": "Nuwave\\Lighthouse\\GraphQL",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/nuwave/lighthouse/src/GraphQL.php",
"line": 110,
"function": "executeQuery",
"class": "Nuwave\\Lighthouse\\GraphQL",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/nuwave/lighthouse/src/Support/Http/Controllers/GraphQLController.php",
"line": 70,
"function": "executeRequest",
"class": "Nuwave\\Lighthouse\\GraphQL",
"type": "->"
},
{
"function": "query",
"class": "Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
"line": 54,
"function": "call_user_func_array"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
"line": 45,
"function": "callAction",
"class": "Illuminate\\Routing\\Controller",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
"line": 219,
"function": "dispatch",
"class": "Illuminate\\Routing\\ControllerDispatcher",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
"line": 176,
"function": "runController",
"class": "Illuminate\\Routing\\Route",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 681,
"function": "run",
"class": "Illuminate\\Routing\\Route",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 130,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/nuwave/lighthouse/src/Support/Http/Middleware/AcceptJson.php",
"line": 30,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 171,
"function": "handle",
"class": "Nuwave\\Lighthouse\\Support\\Http\\Middleware\\AcceptJson",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 105,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 683,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 658,
"function": "runRouteWithinStack",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 624,
"function": "runRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 613,
"function": "dispatchToRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 170,
"function": "dispatch",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 130,
"function": "Illuminate\\Foundation\\Http\\{closure}",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 171,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 171,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
"line": 27,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 171,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php",
"line": 63,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 171,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/fideloper/proxy/src/TrustProxies.php",
"line": 57,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 171,
"function": "handle",
"class": "Fideloper\\Proxy\\TrustProxies",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/spatie/laravel-cors/src/Cors.php",
"line": 41,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 171,
"function": "handle",
"class": "Spatie\\Cors\\Cors",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 105,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 145,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 110,
"function": "sendRequestThroughRouter",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/home/richard/Projects/snaptuity-api/public/index.php",
"line": 55,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/home/richard/.config/composer/vendor/cpriego/valet-linux/server.php",
"line": 232,
"function": "require"
}
]
}
Environment
Lighthouse Version: 4.9/4.10 (tested both)
Laravel Version: 6
@spawnia Actually found out what it was.
There is a bug with the WhereConditionsServiceProvider class. After removing it my graph worked (barring the queries that i had used the experimental where condition on)
After much digging i found out that the way i had installed my packages was all wrong.
mll-lab/graphql-php-scalars
was required by a certain package that we install. however for some reason it wasnt being downloaded at all into the vendor folder probably because of a messed up composer.lock file.
Yeah. I encountered the same problem.
Solved it like this:
In AppServiceProvider class in boot method:
$typeRegistry = app(TypeRegistry::class);
$typeRegistry->register(new MLL\GraphQLScalars\MixedScalar());
The docs explicitly mention that you have to install this package in order for complex where conditions to work:
https://lighthouse-php.com/master/eloquent/complex-where-conditions.html#setup
Just to reiterate, you do need to install that package:
composer require mll-lab/graphql-php-scalars:^4
You also need to add it to config/app.php in the providers section:
'providers' => [
...
\Nuwave\Lighthouse\WhereConditions\WhereConditionsServiceProvider::class,
...
],
And as @talismandev mentionned I had to add some code in app/Providers/AppServiceProvider.php except that code had issues with figuring out where things are for some reason so I ended up with:
<?php
namespace App\Providers;
use Nuwave\Lighthouse\Schema\TypeRegistry;
use MLL\GraphQLScalars\MixedScalar;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register()
{
}
/**
* Bootstrap any application services.
*/
public function boot()
{
$typeRegistry = app(TypeRegistry::class);
$typeRegistry->register(new MixedScalar());
}
}
And then, it worked like a charm! Hope it helps
@spawnia v5 require mll-lab/graphql-php-scalars:^4, maybe we should mention in https://github.com/nuwave/lighthouse/blob/master/UPGRADE.md
@spawnia v5 require
mll-lab/graphql-php-scalars:^4, maybe we should mention in https://github.com/nuwave/lighthouse/blob/master/UPGRADE.md
Definitely, can you create a PR?
Most helpful comment
@spawnia v5 require
mll-lab/graphql-php-scalars:^4, maybe we should mention in https://github.com/nuwave/lighthouse/blob/master/UPGRADE.md