nuwave / lighthouse

A framework for serving GraphQL from Laravel
https://lighthouse-php.com
MIT License
3.37k stars 437 forks source link

Improve validation message when using output types as inputs #2594

Closed spawnia closed 4 months ago

spawnia commented 4 months ago

Resolves https://github.com/nuwave/lighthouse/issues/2593

Changes

The following schema will now trigger a better error message when calling php artisan lighthouse:validate-schema:

type Query {
    foo(foo: Foo): Int
}

type Foo {
    foo: Int
}

Before:

 AssertionError 

 assert($type instanceof Type && $type instanceof InputType)
 at vendor/nuwave/lighthouse/src/Schema/Factories/ArgumentFactory.php:52

After:

GraphQL\Error\InvariantViolation: The type of Query.foo(foo:) must be Input Type but got: Foo.

Breaking changes

None.