Include transformed request in errors

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2543
Co-authored-by: Solomon Bothwell <24038+ssbothwell@users.noreply.github.com>
GitOrigin-RevId: 1432a215cfc2c3e8345941b8072925f115f9259f
This commit is contained in:
Lyndon Maydwell 2021-10-13 11:28:51 +11:00 committed by hasura-bot
parent 1d719eb811
commit 788e5cb0c2
10 changed files with 17 additions and 7 deletions

View File

@ -13,6 +13,7 @@ suffix-less versions. Aliases may be set by both
### Bug fixes and improvements
- server: add transformed request to action error responses
- server: allow nullable action responses (#4405)
- server: add support for openapi json of REST Endpoints
- server: enable inherited roles by default in the graphql-engine

View File

@ -503,13 +503,14 @@ callWebhook
let transformedPayloadSize = HTTP.getReqSize transformedReq
in pure (Just transformedReq, Just transformedPayloadSize)
let actualReq = fromMaybe req transformedReq
httpResponse <-
Tracing.tracedHttpRequest (fromMaybe req transformedReq) $ \request ->
Tracing.tracedHttpRequest actualReq $ \request ->
liftIO . try $ HTTP.performRequest request manager
let requestInfo =
ActionRequestInfo url postPayload $
confHeaders <> toHeadersConf clientHeaders
let requestInfo = ActionRequestInfo url postPayload (confHeaders <> toHeadersConf clientHeaders) transformedReq
case httpResponse of
Left e ->
throw500WithDetail "http exception when calling webhook" $

View File

@ -98,9 +98,10 @@ instance J.ToJSON ActionWebhookResponse where
data ActionRequestInfo = ActionRequestInfo
{ _areqiUrl :: !Text,
_areqiBody :: !J.Value,
_areqiHeaders :: ![HeaderConf]
_areqiHeaders :: ![HeaderConf],
_areqiTransformedRequest :: !(Maybe HTTP.Request)
}
deriving (Show, Eq)
deriving (Show)
$(J.deriveToJSON (J.aesonDrop 6 J.snakeCase) ''ActionRequestInfo)
@ -118,7 +119,7 @@ data ActionInternalError = ActionInternalError
_aieRequest :: !ActionRequestInfo,
_aieResponse :: !(Maybe ActionResponseInfo)
}
deriving (Show, Eq)
deriving (Show)
$(J.deriveToJSON (J.aesonDrop 4 J.snakeCase) ''ActionInternalError)

View File

@ -61,6 +61,7 @@
\ }\n }\n}\n"
url: http://127.0.0.1:5593/create-user
headers: []
transformed_request:
path: $
code: unexpected
message: expecting array for action webhook response but got object

View File

@ -48,6 +48,7 @@
\ id\n }\n}\n"
url: http://127.0.0.1:5593/null-response
headers: []
transformed_request:
path: $
code: unexpected
message: expecting array for action webhook response but got null

View File

@ -64,6 +64,7 @@
\ }\n}\n"
url: http://127.0.0.1:5593/create-users
headers: []
transformed_request:
path: $
code: unexpected
message: expecting object for action webhook response but got array

View File

@ -47,6 +47,7 @@
request_query: "mutation {\n create_user {\n id\n }\n}\n"
url: http://127.0.0.1:5593/null-response
headers: []
transformed_request:
path: $
code: unexpected
message: expecting object for action webhook response but got null

View File

@ -61,6 +61,7 @@
\ }\n }\n}\n"
url: http://127.0.0.1:5593/invalid-response
headers: []
transformed_request:
path: $
code: parse-failed
message: expecting null, object or array of objects for action webhook response

View File

@ -28,6 +28,7 @@ response:
\ id\n name\n }\n}\n"
url: http://127.0.0.1:5593/mirror-action
headers: []
transformed_request:
path: $
code: unexpected
message: field "id" expected in webhook response, but not found

View File

@ -30,6 +30,7 @@ response:
\ $name}){\n id\n name\n }\n}\n"
url: http://127.0.0.1:5593/mirror-action
headers: []
transformed_request:
path: $
code: unexpected
message: expecting not null value for field "id"