Migrate update step changes to diff (#14663)

This PR should fix optimistic rendering issues on step updates:
- compute a diff for trigger and steps on mutations
- build an util that applies that diff (built a more robust version from
https://github.com/AsyncBanana/micropatch)
- apply diff in cache
This commit is contained in:
Thomas Trompette
2025-09-23 18:41:26 +02:00
committed by GitHub
parent a5c47a60d0
commit 6ea7aea92b
31 changed files with 1545 additions and 518 deletions
@@ -0,0 +1,8 @@
import { gql } from '@apollo/client';
export const WORKFLOW_DIFF_FRAGMENT = gql`
fragment WorkflowDiffFragment on WorkflowVersionStepChanges {
triggerDiff
stepsDiff
}
`;
@@ -1,10 +1,12 @@
import { WORKFLOW_DIFF_FRAGMENT } from '@/workflow/graphql/fragments/workflowDiffFragment';
import { gql } from '@apollo/client';
export const CREATE_WORKFLOW_VERSION_EDGE = gql`
mutation CreateWorkflowVersionEdge($input: CreateWorkflowVersionEdgeInput!) {
createWorkflowVersionEdge(input: $input) {
triggerNextStepIds
stepsNextStepIds
...WorkflowDiffFragment
}
}
${WORKFLOW_DIFF_FRAGMENT}
`;
@@ -1,22 +1,12 @@
import { WORKFLOW_DIFF_FRAGMENT } from '@/workflow/graphql/fragments/workflowDiffFragment';
import { gql } from '@apollo/client';
export const CREATE_WORKFLOW_VERSION_STEP = gql`
mutation CreateWorkflowVersionStep($input: CreateWorkflowVersionStepInput!) {
createWorkflowVersionStep(input: $input) {
triggerNextStepIds
stepsNextStepIds
createdStep {
id
name
type
settings
valid
nextStepIds
position {
x
y
}
}
...WorkflowDiffFragment
}
}
${WORKFLOW_DIFF_FRAGMENT}
`;
@@ -1,10 +1,12 @@
import { WORKFLOW_DIFF_FRAGMENT } from '@/workflow/graphql/fragments/workflowDiffFragment';
import { gql } from '@apollo/client';
export const DELETE_WORKFLOW_VERSION_EDGE = gql`
mutation DeleteWorkflowVersionEdge($input: CreateWorkflowVersionEdgeInput!) {
deleteWorkflowVersionEdge(input: $input) {
triggerNextStepIds
stepsNextStepIds
...WorkflowDiffFragment
}
}
${WORKFLOW_DIFF_FRAGMENT}
`;
@@ -1,11 +1,12 @@
import { WORKFLOW_DIFF_FRAGMENT } from '@/workflow/graphql/fragments/workflowDiffFragment';
import { gql } from '@apollo/client';
export const DELETE_WORKFLOW_VERSION_STEP = gql`
mutation DeleteWorkflowVersionStep($input: DeleteWorkflowVersionStepInput!) {
deleteWorkflowVersionStep(input: $input) {
triggerNextStepIds
stepsNextStepIds
deletedStepIds
...WorkflowDiffFragment
}
}
${WORKFLOW_DIFF_FRAGMENT}
`;
@@ -1,3 +1,4 @@
import { WORKFLOW_DIFF_FRAGMENT } from '@/workflow/graphql/fragments/workflowDiffFragment';
import { gql } from '@apollo/client';
export const DUPLICATE_WORKFLOW_VERSION_STEP = gql`
@@ -5,20 +6,9 @@ export const DUPLICATE_WORKFLOW_VERSION_STEP = gql`
$input: DuplicateWorkflowVersionStepInput!
) {
duplicateWorkflowVersionStep(input: $input) {
triggerNextStepIds
stepsNextStepIds
createdStep {
id
name
type
settings
valid
nextStepIds
position {
x
y
}
}
...WorkflowDiffFragment
}
}
${WORKFLOW_DIFF_FRAGMENT}
`;