Dariusz Kuc
02/14/2023, 10:23 PMOne thing our custom graphql ktor layer has is an exception handler in our call handler i.e. the wrapper around the graphql server'scall. This exception handle creates a standard GraphQLResponse for unhandled exceptions -- otherwise we found unexpected errors weren't handled properly by the client side (a 3rd party project using Elm). I haven't checked the PR but would we still have access to this extension point?execute
GraphQLRequestHandler
which should capture all execution exceptions -> https://github.com/ExpediaGroup/graphql-kotlin/blob/master/servers/graphql-kotlin-[…]/expediagroup/graphql/server/execution/GraphQLRequestHandler.kt1. parse request
2. calculate context
3. execute/process request
rocketraman
02/14/2023, 11:03 PMDariusz Kuc
02/14/2023, 11:04 PMrocketraman
02/14/2023, 11:04 PMDariusz Kuc
02/14/2023, 11:08 PMBad Request
if it cannot be parsed -> https://github.com/ExpediaGroup/graphql-kotlin/blob/master/servers/graphql-kotlin-[…]src/main/kotlin/com/expediagroup/graphql/server/ktor/GraphQL.ktrocketraman
02/14/2023, 11:11 PMDariusz Kuc
02/14/2023, 11:12 PMrocketraman
02/14/2023, 11:12 PMDariusz Kuc
02/14/2023, 11:13 PMrocketraman
02/14/2023, 11:13 PMDariusz Kuc
02/14/2023, 11:15 PMIf the GraphQL response does not contain the {data} entry then the server MUST reply with a 4xx or 5xx status code as appropriate.
Note: The GraphQL specification indicates that the only situation in which the GraphQL response does not include the {data} entry is one in which the {errors} entry is populated.
If the GraphQL request is invalid (e.g. it is malformed, or does not pass validation) then the server SHOULD reply with 400 status code.
If the client is not permitted to issue the GraphQL request then the server SHOULD reply with 403, 401 or similar appropriate status code.
rocketraman
02/14/2023, 11:16 PMapplication/graphql-response+json
, along with the 4xx/5xx http status code. I don't believe that is what graphql-kotlin is doing.This section only applies when the response body is to use the application/graphql-response+json media type.
Dariusz Kuc
02/14/2023, 11:18 PMNote: For compatibility with legacy servers, this specification allows the use ofor4xx
status codes for failed requests where the response uses the5xx
media type, but it is strongly discouraged. To useapplication/json
and4xx
status codes, please use the5xx
media type.application/graphql-response+json
rocketraman
02/14/2023, 11:22 PMapplication/json
type in that case.Dariusz Kuc
02/15/2023, 1:24 AM{ "query": "some string", "variables": {}, "operationName": "someString" }
then server should respond with BAD_REQUEST
we already ignore unknown fields so it would only fail IF incoming request does not specify query at all (or query field is not a string)
if the request can be parsed then we will attempt it to process it through graphql engine (which may throw validation errors)Samuel Vazquez
02/15/2023, 1:44 AM