I am fairly new to GraphQL, using Hasura connected to a Postgres DB to expose some REST APIs. I'd like to know if there is a way to insert a queried value in a single GraphQL mutation as a default value.
mutation insertCode($code: String = "", $workcenter: String = "", $order:String = QUERY) {
insert_code_tracing(objects: {code: $code, order: $order, workcenter: $workcenter}) {
returning {
time
}
}
}
Where QUERY would be the following GraphQL query:
query getActiveOrderByWrkcntr($workcenter: String = ""){
orders(order_by: {time: desc_nulls_last}, where: {workcenter: {_eq: $workcenter}}, limit: 1) {
order
workcenter
time
}
}
That fetches a single value given the work center.
Is it possible to specify a queried default value instead of a static one? I'd like to keep the DB consistent without risking making two sequential REST calls to get the value and then pass it to the mutation.