feat: Implement initial version of getExecutions query
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
d4bef44b93
commit
343b360303
16
packages/backend/src/graphql/queries/get-executions.ts
Normal file
16
packages/backend/src/graphql/queries/get-executions.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import Context from '../../types/express/context';
|
||||||
|
|
||||||
|
const getExecutions = async (
|
||||||
|
_parent: unknown,
|
||||||
|
_params: unknown,
|
||||||
|
context: Context
|
||||||
|
) => {
|
||||||
|
const executions = await context.currentUser
|
||||||
|
.$relatedQuery('executions')
|
||||||
|
.withGraphFetched('flow')
|
||||||
|
.orderBy('created_at', 'asc');
|
||||||
|
|
||||||
|
return executions;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getExecutions;
|
@@ -6,6 +6,7 @@ import testConnection from './queries/test-connection';
|
|||||||
import getFlow from './queries/get-flow';
|
import getFlow from './queries/get-flow';
|
||||||
import getFlows from './queries/get-flows';
|
import getFlows from './queries/get-flows';
|
||||||
import getStepWithTestExecutions from './queries/get-step-with-test-executions';
|
import getStepWithTestExecutions from './queries/get-step-with-test-executions';
|
||||||
|
import getExecutions from './queries/get-executions';
|
||||||
|
|
||||||
const queryResolvers = {
|
const queryResolvers = {
|
||||||
getApps,
|
getApps,
|
||||||
@@ -16,6 +17,7 @@ const queryResolvers = {
|
|||||||
getFlow,
|
getFlow,
|
||||||
getFlows,
|
getFlows,
|
||||||
getStepWithTestExecutions,
|
getStepWithTestExecutions,
|
||||||
|
getExecutions,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default queryResolvers;
|
export default queryResolvers;
|
||||||
|
@@ -7,6 +7,7 @@ type Query {
|
|||||||
getFlow(id: String!): Flow
|
getFlow(id: String!): Flow
|
||||||
getFlows: [Flow]
|
getFlows: [Flow]
|
||||||
getStepWithTestExecutions(stepId: String!): [Step]
|
getStepWithTestExecutions(stepId: String!): [Step]
|
||||||
|
getExecutions: [Execution]
|
||||||
}
|
}
|
||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
@@ -168,6 +169,14 @@ type Flow {
|
|||||||
steps: [Step]
|
steps: [Step]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Execution {
|
||||||
|
id: String
|
||||||
|
testRun: Boolean
|
||||||
|
createdAt: String
|
||||||
|
updatedAt: String
|
||||||
|
flow: Flow
|
||||||
|
}
|
||||||
|
|
||||||
input CreateConnectionInput {
|
input CreateConnectionInput {
|
||||||
key: AvailableAppsEnumType!
|
key: AvailableAppsEnumType!
|
||||||
formattedData: JSONObject!
|
formattedData: JSONObject!
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { ValidationError } from 'objection';
|
import { ValidationError } from 'objection';
|
||||||
import Base from './base';
|
import Base from './base';
|
||||||
import Step from './step';
|
import Step from './step';
|
||||||
|
import Execution from './execution';
|
||||||
|
|
||||||
class Flow extends Base {
|
class Flow extends Base {
|
||||||
id!: string;
|
id!: string;
|
||||||
@@ -31,6 +32,14 @@ class Flow extends Base {
|
|||||||
to: 'steps.flow_id',
|
to: 'steps.flow_id',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
executions: {
|
||||||
|
relation: Base.HasManyRelation,
|
||||||
|
modelClass: Execution,
|
||||||
|
join: {
|
||||||
|
from: 'flows.id',
|
||||||
|
to: 'executions.flow_id',
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
async $beforeUpdate(): Promise<void> {
|
async $beforeUpdate(): Promise<void> {
|
||||||
|
@@ -3,6 +3,7 @@ import Base from './base';
|
|||||||
import Connection from './connection';
|
import Connection from './connection';
|
||||||
import Flow from './flow';
|
import Flow from './flow';
|
||||||
import Step from './step';
|
import Step from './step';
|
||||||
|
import Execution from './execution';
|
||||||
import bcrypt from 'bcrypt';
|
import bcrypt from 'bcrypt';
|
||||||
|
|
||||||
class User extends Base {
|
class User extends Base {
|
||||||
@@ -55,6 +56,18 @@ class User extends Base {
|
|||||||
to: 'steps.flow_id',
|
to: 'steps.flow_id',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
executions: {
|
||||||
|
relation: Base.ManyToManyRelation,
|
||||||
|
modelClass: Execution,
|
||||||
|
join: {
|
||||||
|
from: 'users.id',
|
||||||
|
through: {
|
||||||
|
from: 'flows.user_id',
|
||||||
|
to: 'flows.id',
|
||||||
|
},
|
||||||
|
to: 'executions.flow_id',
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
login(password: string) {
|
login(password: string) {
|
||||||
|
Reference in New Issue
Block a user