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

Improve validation message when using output types as inputs #2594

Merged
merged 3 commits into from
Jul 25, 2024

Conversation

spawnia
Copy link
Collaborator

@spawnia spawnia commented Jul 25, 2024

Resolves #2593

  • Added or updated tests
  • Documented user facing changes
  • Updated CHANGELOG.md

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.

@spawnia spawnia marked this pull request as ready for review July 25, 2024 09:46
@spawnia spawnia added the enhancement A feature or improvement label Jul 25, 2024
@spawnia spawnia merged commit c091948 into master Jul 25, 2024
41 checks passed
@spawnia spawnia deleted the validate-output-type-used-as-input branch July 25, 2024 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detection of incorrect type usage in input, or vice versa
1 participant