chore: Order steps by position ascending

This commit is contained in:
Faruk AYDIN
2022-01-28 18:29:54 +03:00
committed by Ali BARIN
parent 60b0b02de2
commit bb3183959e

View File

@@ -4,24 +4,26 @@ import RequestWithCurrentUser from '../../types/express/request-with-current-use
import flowType from '../types/flow'; import flowType from '../types/flow';
type Params = { type Params = {
id: number id: number;
} };
const getFlowResolver = async (params: Params, req: RequestWithCurrentUser) => { const getFlowResolver = async (params: Params, req: RequestWithCurrentUser) => {
const flow = await Flow.query() const flow = await Flow.query()
.withGraphJoined('[steps.[connection]]') .withGraphJoined('[steps.[connection]]')
.orderBy('steps.position', 'asc')
.findOne({ 'flows.user_id': req.currentUser.id, 'flows.id': params.id }) .findOne({ 'flows.user_id': req.currentUser.id, 'flows.id': params.id })
.throwIfNotFound(); .throwIfNotFound();
return flow; return flow;
} };
const getFlow = { const getFlow = {
type: flowType, type: flowType,
args: { args: {
id: { type: GraphQLNonNull(GraphQLInt) }, id: { type: GraphQLNonNull(GraphQLInt) },
}, },
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => getFlowResolver(params, req) resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
} getFlowResolver(params, req),
};
export default getFlow; export default getFlow;