feat: Implement updateFlowStatus mutation

This commit is contained in:
Faruk AYDIN
2022-03-07 20:35:05 +03:00
committed by Ömer Faruk Aydın
parent 63198a6569
commit 64011b5c4b
4 changed files with 36 additions and 4 deletions

View File

@@ -0,0 +1,31 @@
import Context from '../../types/express/context';
type Params = {
id: string;
active: boolean;
};
const updateFlowStatus = async (
_parent: unknown,
params: Params,
context: Context
) => {
let flow = await context.currentUser
.$relatedQuery('flows')
.findOne({
id: params.id,
})
.throwIfNotFound();
if (flow.active === params.active) {
return flow;
}
flow = await flow.$query().patchAndFetch({
active: params.active,
});
return flow;
};
export default updateFlowStatus;