diff --git a/packages/backend/src/graphql/queries/get-step-with-test-executions.js b/packages/backend/src/graphql/queries/get-step-with-test-executions.js
deleted file mode 100644
index 5ec088b0..00000000
--- a/packages/backend/src/graphql/queries/get-step-with-test-executions.js
+++ /dev/null
@@ -1,34 +0,0 @@
-import { ref } from 'objection';
-import ExecutionStep from '../../models/execution-step.js';
-import Step from '../../models/step.js';
-
-const getStepWithTestExecutions = 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()
- .findOne({ 'steps.id': params.stepId })
- .throwIfNotFound();
-
- const previousStepsWithCurrentStep = await stepBaseQuery
- .clone()
- .withGraphJoined('executionSteps')
- .where('flow_id', '=', step.flowId)
- .andWhere('position', '<', step.position)
- .andWhere(
- 'executionSteps.created_at',
- '=',
- ExecutionStep.query()
- .max('created_at')
- .where('step_id', '=', ref('steps.id'))
- .andWhere('status', 'success')
- )
- .orderBy('steps.position', 'asc');
-
- return previousStepsWithCurrentStep;
-};
-
-export default getStepWithTestExecutions;
diff --git a/packages/backend/src/graphql/query-resolvers.js b/packages/backend/src/graphql/query-resolvers.js
index 68308897..23888476 100644
--- a/packages/backend/src/graphql/query-resolvers.js
+++ b/packages/backend/src/graphql/query-resolvers.js
@@ -1,14 +1,12 @@
import getAppAuthClient from './queries/get-app-auth-client.ee.js';
import getConnectedApps from './queries/get-connected-apps.js';
import getDynamicData from './queries/get-dynamic-data.js';
-import getStepWithTestExecutions from './queries/get-step-with-test-executions.js';
import testConnection from './queries/test-connection.js';
const queryResolvers = {
getAppAuthClient,
getConnectedApps,
getDynamicData,
- getStepWithTestExecutions,
testConnection,
};
diff --git a/packages/backend/src/graphql/schema.graphql b/packages/backend/src/graphql/schema.graphql
index 17e35206..250fe32b 100644
--- a/packages/backend/src/graphql/schema.graphql
+++ b/packages/backend/src/graphql/schema.graphql
@@ -2,7 +2,6 @@ type Query {
getAppAuthClient(id: String!): AppAuthClient
getConnectedApps(name: String): [App]
testConnection(id: String!): Connection
- getStepWithTestExecutions(stepId: String!): [Step]
getDynamicData(
stepId: String!
key: String!
diff --git a/packages/web/src/components/FlowStep/index.jsx b/packages/web/src/components/FlowStep/index.jsx
index b5bb79b9..ef181bb8 100644
--- a/packages/web/src/components/FlowStep/index.jsx
+++ b/packages/web/src/components/FlowStep/index.jsx
@@ -1,6 +1,5 @@
import PropTypes from 'prop-types';
import * as React from 'react';
-import { useLazyQuery } from '@apollo/client';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
@@ -24,7 +23,7 @@ import ChooseConnectionSubstep from 'components/ChooseConnectionSubstep';
import Form from 'components/Form';
import FlowStepContextMenu from 'components/FlowStepContextMenu';
import AppIcon from 'components/AppIcon';
-import { GET_STEP_WITH_TEST_EXECUTIONS } from 'graphql/queries/get-step-with-test-executions';
+
import useFormatMessage from 'hooks/useFormatMessage';
import useApps from 'hooks/useApps';
import {
@@ -40,6 +39,7 @@ import useTriggers from 'hooks/useTriggers';
import useActions from 'hooks/useActions';
import useTriggerSubsteps from 'hooks/useTriggerSubsteps';
import useActionSubsteps from 'hooks/useActionSubsteps';
+import useStepWithTestExecutions from 'hooks/useStepWithTestExecutions';
const validIcon = ;
const errorIcon = ;
@@ -126,28 +126,16 @@ function FlowStep(props) {
const { data: apps } = useApps(useAppsOptions);
- const [
- getStepWithTestExecutions,
- { data: stepWithTestExecutionsData, called: stepWithTestExecutionsCalled },
- ] = useLazyQuery(GET_STEP_WITH_TEST_EXECUTIONS, {
- fetchPolicy: 'network-only',
- });
+ const { data: stepWithTestExecutions, refetch } = useStepWithTestExecutions(
+ step.id,
+ );
+ const stepWithTestExecutionsData = stepWithTestExecutions?.data;
React.useEffect(() => {
- if (!stepWithTestExecutionsCalled && !collapsed && !isTrigger) {
- getStepWithTestExecutions({
- variables: {
- stepId: step.id,
- },
- });
+ if (!collapsed && !isTrigger) {
+ refetch(step.id);
}
- }, [
- collapsed,
- stepWithTestExecutionsCalled,
- getStepWithTestExecutions,
- step.id,
- isTrigger,
- ]);
+ }, [collapsed, refetch, step.id, isTrigger]);
const app = apps?.data?.find((currentApp) => currentApp.key === step.appKey);
@@ -274,9 +262,7 @@ function FlowStep(props) {
-
+