feat: Implement getData query and send a message action for slack
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
f8c7b85682
commit
8512528fcf
31
packages/backend/src/graphql/queries/get-data.ts
Normal file
31
packages/backend/src/graphql/queries/get-data.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import App from '../../models/app';
|
||||
import Connection from '../../models/connection';
|
||||
import Step from '../../models/step';
|
||||
import { IApp } from '@automatisch/types';
|
||||
import Context from '../../types/express/context';
|
||||
import ListData from '../../apps/slack/data/list-channels';
|
||||
|
||||
type Params = {
|
||||
stepId: string;
|
||||
key: string;
|
||||
};
|
||||
|
||||
const getData = async (_parent: unknown, params: Params, context: Context) => {
|
||||
const step = await context.currentUser
|
||||
.$relatedQuery('steps')
|
||||
.withGraphFetched('connection')
|
||||
.findById(params.stepId);
|
||||
|
||||
const connection = step.connection;
|
||||
|
||||
const appData = App.findOneByKey(step.appKey);
|
||||
const AppClass = (await import(`../../apps/${step.appKey}`)).default;
|
||||
|
||||
const appInstance = new AppClass(appData, connection.formattedData);
|
||||
const command = appInstance.data[params.key];
|
||||
const fetchedData = await command.run();
|
||||
|
||||
return fetchedData;
|
||||
};
|
||||
|
||||
export default getData;
|
@@ -8,6 +8,7 @@ import getFlows from './queries/get-flows';
|
||||
import getStepWithTestExecutions from './queries/get-step-with-test-executions';
|
||||
import getExecutions from './queries/get-executions';
|
||||
import getExecutionSteps from './queries/get-execution-steps';
|
||||
import getData from './queries/get-data';
|
||||
|
||||
const queryResolvers = {
|
||||
getApps,
|
||||
@@ -20,6 +21,7 @@ const queryResolvers = {
|
||||
getStepWithTestExecutions,
|
||||
getExecutions,
|
||||
getExecutionSteps,
|
||||
getData,
|
||||
};
|
||||
|
||||
export default queryResolvers;
|
||||
|
@@ -13,6 +13,7 @@ type Query {
|
||||
limit: Int!
|
||||
offset: Int!
|
||||
): ExecutionStepConnection
|
||||
getData(stepId: String!, key: String!): JSONObject
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
@@ -48,22 +49,34 @@ type Action {
|
||||
name: String
|
||||
key: String
|
||||
description: String
|
||||
subSteps: [ActionSubStep]
|
||||
substeps: [ActionSubstep]
|
||||
}
|
||||
|
||||
type ActionSubStep {
|
||||
type ActionSubstep {
|
||||
key: String
|
||||
name: String
|
||||
arguments: [ActionSubStepArgument]
|
||||
arguments: [ActionSubstepArgument]
|
||||
}
|
||||
|
||||
type ActionSubStepArgument {
|
||||
type ActionSubstepArgument {
|
||||
label: String
|
||||
key: String
|
||||
type: String
|
||||
description: String
|
||||
required: Boolean
|
||||
variables: Boolean
|
||||
source: ActionSubstepArgumentSource
|
||||
}
|
||||
|
||||
type ActionSubstepArgumentSource {
|
||||
type: String
|
||||
name: String
|
||||
arguments: [ActionSubstepArgumentSourceArgument]
|
||||
}
|
||||
|
||||
type ActionSubstepArgumentSourceArgument {
|
||||
name: String
|
||||
value: String
|
||||
}
|
||||
|
||||
type App {
|
||||
@@ -337,16 +350,16 @@ type Trigger {
|
||||
name: String
|
||||
key: String
|
||||
description: String
|
||||
subSteps: [TriggerSubStep]
|
||||
substeps: [TriggerSubstep]
|
||||
}
|
||||
|
||||
type TriggerSubStep {
|
||||
type TriggerSubstep {
|
||||
key: String
|
||||
name: String
|
||||
arguments: [TriggerSubStepArgument]
|
||||
arguments: [TriggerSubstepArgument]
|
||||
}
|
||||
|
||||
type TriggerSubStepArgument {
|
||||
type TriggerSubstepArgument {
|
||||
label: String
|
||||
key: String
|
||||
type: String
|
||||
|
Reference in New Issue
Block a user