chore: Order steps by position ascending
This commit is contained in:
@@ -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]]')
|
||||||
.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();
|
.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;
|
||||||
|
Reference in New Issue
Block a user