feat: Implement deleteFlow mutation
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
3429784309
commit
b822e25359
32
packages/backend/src/graphql/mutations/delete-flow.ts
Normal file
32
packages/backend/src/graphql/mutations/delete-flow.ts
Normal 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;
|
Reference in New Issue
Block a user