Files
automatisch/packages/backend/src/graphql/queries/get-flow.ts
2022-01-29 18:50:55 +03:00

30 lines
757 B
TypeScript

import { GraphQLNonNull, GraphQLString } from 'graphql';
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
import flowType from '../types/flow';
type Params = {
id: string;
};
const getFlowResolver = async (params: Params, req: RequestWithCurrentUser) => {
const flow = await req.currentUser
.$relatedQuery('flows')
.withGraphJoined('[steps.[connection]]')
.orderBy('steps.position', 'asc')
.findOne({ 'flows.id': params.id })
.throwIfNotFound();
return flow;
};
const getFlow = {
type: flowType,
args: {
id: { type: GraphQLNonNull(GraphQLString) },
},
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
getFlowResolver(params, req),
};
export default getFlow;