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';
type Params = {
id: number
}
id: number;
};
const getFlowResolver = async (params: Params, req: RequestWithCurrentUser) => {
const flow = await Flow.query()
.withGraphJoined('[steps.[connection]]')
.findOne({'flows.user_id': req.currentUser.id, 'flows.id': params.id})
.orderBy('steps.position', 'asc')
.findOne({ 'flows.user_id': req.currentUser.id, 'flows.id': params.id })
.throwIfNotFound();
return flow;
}
};
const getFlow = {
type: flowType,
args: {
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;