feat: Implement deleteFlow mutation

This commit is contained in:
Faruk AYDIN
2022-01-30 12:38:35 +03:00
committed by Ömer Faruk Aydın
parent 3429784309
commit b822e25359
3 changed files with 35 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
import { GraphQLString, GraphQLNonNull, GraphQLBoolean } from 'graphql';
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
type Params = {
id: string;
};
const deleteFlowResolver = async (
params: Params,
req: RequestWithCurrentUser
) => {
await req.currentUser
.$relatedQuery('flows')
.delete()
.findOne({
id: params.id,
})
.throwIfNotFound();
return;
};
const deleteFlow = {
type: GraphQLBoolean,
args: {
id: { type: GraphQLNonNull(GraphQLString) },
},
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
deleteFlowResolver(params, req),
};
export default deleteFlow;