hasura / hasura/graphql-engine
Access async action id inside of action
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Discussed in https://github.com/hasura/graphql-engine/discussions/8750
Originally posted by **talgat-ruby** August 5, 2022
Hi
For example, lets say I have async action `someAsyncAction`. I can access `action_id` in the **client** via graphql.
```graphql
mutation SomeAsyncActionRequest($name: String!) {
someAsyncAction(name: $name)
}
```
```json
{
"data": {
"someAsyncAction": "23b1c256-7aff-4b95-95bd-68220d9f93f2"
}
}
```
But this is **client**. How about within action code? I want to save the `action_id` ro db to show its status only for a particular user.
```js
module.exports = async (req, res) => {
const { input, action } = req.body // can access action description: name, but why not id?
const { name } = input
try {
const resp = await heavyRequest(name)
res.send({
success: resp.data.success
})
} catch (err) {
res.status(400).json({
message: err.message
})
}
}
```
The only workaround I found is to Proxy asynchronous action with synchronous action. Isn't it overhead.
Contributor guide
Assessment
This issue has not been assessed yet.