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

500 error for unknown types in variable definitions #1936

Closed
andershagbard opened this issue Sep 15, 2021 · 3 comments · Fixed by webonyx/graphql-php#1038
Closed

500 error for unknown types in variable definitions #1936

andershagbard opened this issue Sep 15, 2021 · 3 comments · Fixed by webonyx/graphql-php#1038
Labels
bug An error within Lighthouse

Comments

@andershagbard
Copy link
Contributor

Describe the bug

It returns 500 server error, if you are sending an unknown type in the orderByDirective.

Expected behavior/Solution

It should send some kind of GraphQL incorrect format response.

Steps to reproduce

  1. Create a query which is using the orderBy directive
  2. Define your query on the client side. E.g.:
query(
  $page: Int!
  $first: Int!
  $orderBy: [UNKNOWN_TYPE!]
) {
  ...
  1. Send query

Output/Logs

Click to expand
[2021-09-15 14:49:55] local.ERROR: Lighthouse failed while trying to load a type: OrdersOrderByOrderByClause

Make sure the type is present in your schema definition.
 {"userId":1,"exception":"[object] (Nuwave\\Lighthouse\\Exceptions\\DefinitionException(code: 0): Lighthouse failed while trying to load a type: UNKNOWN_TYPE

Make sure the type is present in your schema definition.

Lighthouse Version

5.23

@spawnia spawnia added the needs reproduction Failing test case needed label Sep 30, 2021
@spawnia spawnia changed the title 500 error if unknown type sent client side in orderByDirective 500 error for unknown types in argument definitions Sep 30, 2021
@spawnia spawnia changed the title 500 error for unknown types in argument definitions 500 error for unknown types in variable definitions Sep 30, 2021
@spawnia spawnia added bug An error within Lighthouse and removed needs reproduction Failing test case needed labels Sep 30, 2021
@spawnia
Copy link
Collaborator

spawnia commented Sep 30, 2021

Thanks for the report. This issue applies more broadly to any unknown type in any variable definition, see #1943 for reproduction.

I think this should be fixed upstream in https://github.com/webonyx/graphql-php. There is a validation rule in the GraphQL specification governing that variables must be input types, but it does not explicitly mention that the defined type must also exist: http://spec.graphql.org/draft/#sec-Variables-Are-Input-Types. I think because of this, no explicit test for proper handling of this case exists in the library.

@spawnia
Copy link
Collaborator

spawnia commented Sep 30, 2021

I opened a pull request against the reference implementation to add a validation step for this: graphql/graphql-js#3282

@andershagbard
Copy link
Contributor Author

andershagbard commented Dec 15, 2021

Looks like this is solved upstream now graphql/graphql-js#3284

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error within Lighthouse
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants