Merge pull request #1764 from automatisch/AUT-872
refactor: rewrite useDynamicFields with RQ
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
import App from '../../models/app.js';
|
||||
import Step from '../../models/step.js';
|
||||
import globalVariable from '../../helpers/global-variable.js';
|
||||
|
||||
const getDynamicFields = async (_parent, params, context) => {
|
||||
const conditions = context.currentUser.can('update', 'Flow');
|
||||
const userSteps = context.currentUser.$relatedQuery('steps');
|
||||
const allSteps = Step.query();
|
||||
const stepBaseQuery = conditions.isCreator ? userSteps : allSteps;
|
||||
|
||||
const step = await stepBaseQuery
|
||||
.clone()
|
||||
.withGraphFetched({
|
||||
connection: true,
|
||||
flow: true,
|
||||
})
|
||||
.findById(params.stepId);
|
||||
|
||||
if (!step) return null;
|
||||
|
||||
const connection = step.connection;
|
||||
|
||||
if (!step.appKey) return null;
|
||||
|
||||
const app = await App.findOneByKey(step.appKey);
|
||||
const $ = await globalVariable({ connection, app, flow: step.flow, step });
|
||||
|
||||
const command = app.dynamicFields.find((data) => data.key === params.key);
|
||||
|
||||
for (const parameterKey in params.parameters) {
|
||||
const parameterValue = params.parameters[parameterKey];
|
||||
$.step.parameters[parameterKey] = parameterValue;
|
||||
}
|
||||
|
||||
const additionalFields = (await command.run($)) || [];
|
||||
|
||||
return additionalFields;
|
||||
};
|
||||
|
||||
export default getDynamicFields;
|
@@ -4,7 +4,6 @@ import getAppAuthClients from './queries/get-app-auth-clients.ee.js';
|
||||
import getBillingAndUsage from './queries/get-billing-and-usage.ee.js';
|
||||
import getConnectedApps from './queries/get-connected-apps.js';
|
||||
import getDynamicData from './queries/get-dynamic-data.js';
|
||||
import getDynamicFields from './queries/get-dynamic-fields.js';
|
||||
import getFlow from './queries/get-flow.js';
|
||||
import getStepWithTestExecutions from './queries/get-step-with-test-executions.js';
|
||||
import testConnection from './queries/test-connection.js';
|
||||
@@ -16,7 +15,6 @@ const queryResolvers = {
|
||||
getBillingAndUsage,
|
||||
getConnectedApps,
|
||||
getDynamicData,
|
||||
getDynamicFields,
|
||||
getFlow,
|
||||
getStepWithTestExecutions,
|
||||
testConnection,
|
||||
|
@@ -11,11 +11,6 @@ type Query {
|
||||
key: String!
|
||||
parameters: JSONObject
|
||||
): JSONObject
|
||||
getDynamicFields(
|
||||
stepId: String!
|
||||
key: String!
|
||||
parameters: JSONObject
|
||||
): [SubstepArgument]
|
||||
getBillingAndUsage: GetBillingAndUsage
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user