-
Notifications
You must be signed in to change notification settings - Fork 2.8k
add a new field extensions in the ActionWebhookErrorResponse, close #4001
#4351
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
add a new field extensions in the ActionWebhookErrorResponse, close #4001
#4351
Conversation
- the extensions can take any json
|
Review app for commit 3b85b73 deployed to Heroku: https://hge-ci-pull-4351.herokuapp.com |
|
|
||
| | HTTP.statusIsClientError responseStatus -> do | ||
| ActionWebhookErrorResponse message maybeCode <- | ||
| ActionWebhookErrorResponse message maybeCode maybeExtension <- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not take code anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See spec: #4001 (comment)
It is find to do this "breaking" change because we introduced it in beta.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept code thinking about the breaking change, I'll fix this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codingkarthik Cool. Also, could you also update the docs with this PR itself? This section: https://hasura.io/docs/1.0/graphql/manual/actions/action-handlers.html#returning-an-error-response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll make the changes
|
Deploy preview for hasura-docs ready! Built with commit 6b5c579 |
|
Review app for commit e6ffc0a deployed to Heroku: https://hge-ci-pull-4351.herokuapp.com |
| = ActionWebhookErrorExtension | ||
| { _aweeExtension :: !J.Value | ||
| } | ||
| $(J.deriveJSON (J.aesonDrop 5 J.snakeCase) ''ActionWebhookErrorExtension) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a new type which is just a wrapper over J.Value.
| qErr = QErr [] responseStatus message code Nothing | ||
| let qErr = QErr [] responseStatus message Unexpected $ | ||
| (maybe Nothing (Just . J.toJSON . ActionWebhookErrorExtension) maybeExtension) | ||
| throwError qErr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qeInternal of QErr will go into extensions -> internal of the response json. So the response look like
extensions:
internal:
extensions: response-json-from-webhook
See encodeGQLErr function.
I'd suggest to model the extensions in the QErr type.
+data ErrorExtra
+ = EEInternal !Value
+ | EEExtensions !Value
+ deriving (Show, Eq)
+
+instance ToJSON ErrorExtra where
+ toJSON = \case
+ EEInternal v -> v
+ EEExtensions v -> v
+
data QErr
= QErr
- { qePath :: !JSONPath
- , qeStatus :: !N.Status
- , qeError :: !T.Text
- , qeCode :: !Code
- , qeInternal :: !(Maybe Value)
+ { qePath :: !JSONPath
+ , qeStatus :: !N.Status
+ , qeError :: !T.Text
+ , qeCode :: !Code
+ , qeExtra :: !(Maybe ErrorExtra)
} deriving (Show, Eq)
instance ToJSON QErr where
@@ -157,12 +167,12 @@ instance ToJSON QErr where
, "error" .= msg
, "code" .= show code
]
- toJSON (QErr jPath _ msg code (Just ie)) =
+ toJSON (QErr jPath _ msg code (Just extra)) =
object
[ "path" .= encodeJSONPath jPath
, "error" .= msg
, "code" .= show code
- , "internal" .= ie
+ , "internal" .= extra
]
noInternalQErrEnc :: QErr -> Value
@@ -174,18 +184,20 @@ noInternalQErrEnc (QErr jPath _ msg code _) =
]
encodeGQLErr :: Bool -> QErr -> Value
-encodeGQLErr includeInternal (QErr jPath _ msg code mIE) =
+encodeGQLErr includeInternal (QErr jPath _ msg code mExtra) =
object
[ "message" .= msg
, "extensions" .= extnsObj
]
where
- extnsObj = object $ bool codeAndPath
- (codeAndPath ++ internal) includeInternal
+ extnsObj = case mExtra of
+ Nothing -> object codeAndPath
+ Just (EEExtensions v) -> v
+ Just (EEInternal v) -> object $
+ bool codeAndPath (codeAndPath ++ ["internal" .= v]) includeInternal
codeAndPath = [ "code" .= show code
, "path" .= encodeJSONPath jPath
]
- internal = maybe [] (\ie -> ["internal" .= ie]) mIE
rakeshkky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add python tests. Also try to document the new types the PR introduces. In this case, for the suggested ErrorExtra type,
data ErrorExtra
= EEInternal !Value
-- ^ Additional information for the server internal errors.
| EEExtensions !Value
-- ^ Custom extensions json value found in actions webhook response.
deriving (Show, Eq)
marionschleifer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changelog approved.
- ErrorExtra is used to give the errors context while deriving to JSON
|
Review app for commit f67eb3a deployed to Heroku: https://hge-ci-pull-4351.herokuapp.com |
|
Review app for commit 37210c8 deployed to Heroku: https://hge-ci-pull-4351.herokuapp.com |
|
Review app for commit 6b5c579 deployed to Heroku: https://hge-ci-pull-4351.herokuapp.com |
|
Superseded by 8bfcd9a |
fixes #4001
Description
Changelog
CHANGELOG.mdis updated with user-facing content relevant to this PR.Affected components
Related Issues
Solution and Design
Steps to test and verify
Limitations, known bugs & workarounds
Server checklist
Catalog upgrade
Does this PR change Hasura Catalog version?
Metadata
Does this PR add a new Metadata feature?
run_sqlauto manages the new metadata through schema diffing?run_sqlauto manages the definitions of metadata on renaming?export_metadata/replace_metadatasupports the new metadata added?GraphQL
Breaking changes
No Breaking changes
There are breaking changes:
Metadata API
Existing
querytypes:argspayload which is not backward compatibleJSONschemaGraphQL API
Schema Generation:
NamedTypeSchema Resolve:-
nullvalue for any input fieldsLogging
JSONschema has changedtypenames have changed