graphqlite icon indicating copy to clipboard operation
graphqlite copied to clipboard

graphql api returns 500 http codes on unknown types

Open massimilianobraglia opened this issue 3 years ago • 3 comments

Hey there,

query foobar($foobar: Foobar!){
  foobar(foobar: $foobar){
    foobar
  }
}

Calling this query on an environment that has no Foobar type defined results in a 500 http response like in this screenshot.

Is it normal? Shouldn't it be a 400 response?

image

massimilianobraglia avatar Apr 15 '21 14:04 massimilianobraglia

Yes. I think there are a few cases where the http response codes aren't being properly set. Care to submit a pull request?

oojacoboo avatar Apr 16 '21 00:04 oojacoboo

I'll try to find some time for this one! Not sure when :/

massimilianobraglia avatar Apr 16 '21 16:04 massimilianobraglia

@massimilianobraglia be a great time to get a PR merged in. Thanks.

oojacoboo avatar Jun 12 '22 03:06 oojacoboo

I'll try to solve this issue. @oojacoboo any suggestions about the test case?

sebcar avatar Nov 13 '23 12:11 sebcar

@sebcar I think an example like the one mentioned should be sufficient here. There are a few other cases as well, where GQL syntax results in a 500. I'm not sure of all these cases though. GraphQLite uses Webonyx's GQL parser under the hood. I don't think we'll be able to wrap that in a try/catch either, unless there is a specific Exception being thrown for these parsing errors.

oojacoboo avatar Nov 16 '23 12:11 oojacoboo

I can't find a way in the test case to get the execution result for CannotMapTypeException

sebcar avatar Nov 21 '23 11:11 sebcar

@sebcar If there is an exception being thrown, why would there be a result? Presumably, execution was halted before there was a result.

oojacoboo avatar Nov 21 '23 16:11 oojacoboo

@oojacoboo that is true. I was trying to use the HttpCodeDeciderTest

sebcar avatar Nov 21 '23 16:11 sebcar