feat: Convert all query files to JS
This commit is contained in:
19
packages/backend/src/graphql/queries/get-flow.js
Normal file
19
packages/backend/src/graphql/queries/get-flow.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import Flow from '../../models/flow';
|
||||
|
||||
const getFlow = async (_parent, params, context) => {
|
||||
const conditions = context.currentUser.can('read', 'Flow');
|
||||
const userFlows = context.currentUser.$relatedQuery('flows');
|
||||
const allFlows = Flow.query();
|
||||
const baseQuery = conditions.isCreator ? userFlows : allFlows;
|
||||
|
||||
const flow = await baseQuery
|
||||
.clone()
|
||||
.withGraphJoined('[steps.[connection]]')
|
||||
.orderBy('steps.position', 'asc')
|
||||
.findOne({ 'flows.id': params.id })
|
||||
.throwIfNotFound();
|
||||
|
||||
return flow;
|
||||
};
|
||||
|
||||
export default getFlow;
|
Reference in New Issue
Block a user