Files
automatisch/packages/backend/src/graphql/queries/get-flow.ts
2023-07-18 21:03:29 +00:00

21 lines
470 B
TypeScript

import Context from '../../types/express/context';
type Params = {
id: string;
};
const getFlow = async (_parent: unknown, params: Params, context: Context) => {
context.currentUser.can('read', 'Flow');
const flow = await context.currentUser
.$relatedQuery('flows')
.withGraphJoined('[steps.[connection]]')
.orderBy('steps.position', 'asc')
.findOne({ 'flows.id': params.id })
.throwIfNotFound();
return flow;
};
export default getFlow;