Move the workflow draft version overriding to the backend (#9328)
- In the `formatFieldMetadataValue` function, allow people to call TypeORM's `save()` method with unserialized JSON data. - Create an `overrideWorkflowDraftVersion` mutation that takes a workflow id and the id of the workflow version to use as the new draft - If no draft exists yet, create one - If a draft already exists, deactivate its serverless functions - Duplicate every step. For serverless function steps, it includes duplicating the functions - Save the data of the step in DB - Call the `overrideWorkflowDraftVersion` mutation in the old workflow header and in the new Cmd+K actions - I chose to not update the Apollo cache manually as the information of the new draft are going to be automatically fetched once the user lands on the workflow's show page. Note that we redirect the user to this page after overriding the draft version.
This commit is contained in:
committed by
GitHub
parent
7d3c8b440c
commit
17bf2b6173
@ -0,0 +1,23 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import {
|
||||
CreateDraftFromWorkflowVersionInput,
|
||||
useCreateDraftFromWorkflowVersionMutation,
|
||||
} from '~/generated/graphql';
|
||||
|
||||
export const useCreateDraftFromWorkflowVersion = () => {
|
||||
const apolloClient = useApolloClient();
|
||||
|
||||
const [mutate] = useCreateDraftFromWorkflowVersionMutation({
|
||||
client: apolloClient,
|
||||
});
|
||||
|
||||
const createDraftFromWorkflowVersion = async (
|
||||
input: CreateDraftFromWorkflowVersionInput,
|
||||
) => {
|
||||
await mutate({ variables: { input } });
|
||||
};
|
||||
|
||||
return {
|
||||
createDraftFromWorkflowVersion,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user