Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refetch query on draft creation #9650

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/twenty-front/src/generated/graphql.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Apollo from '@apollo/client';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
Expand Down Expand Up @@ -1532,7 +1532,8 @@ export enum WorkspaceActivationStatus {
Active = 'ACTIVE',
Inactive = 'INACTIVE',
OngoingCreation = 'ONGOING_CREATION',
PendingCreation = 'PENDING_CREATION'
PendingCreation = 'PENDING_CREATION',
Suspended = 'SUSPENDED'
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?


export type WorkspaceEdge = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useFindManyRecordsQuery } from '@/object-record/hooks/useFindManyRecordsQuery';
import { useApolloClient } from '@apollo/client';
import {
CreateDraftFromWorkflowVersionInput,
Expand All @@ -11,10 +13,33 @@ export const useCreateDraftFromWorkflowVersion = () => {
client: apolloClient,
});

const { findManyRecordsQuery: findManyWorkflowsQuery } =
useFindManyRecordsQuery({
objectNameSingular: CoreObjectNameSingular.Workflow,
recordGqlFields: {
id: true,
name: true,
statuses: true,
lastPublishedVersionId: true,
versions: true,
},
});

const createDraftFromWorkflowVersion = async (
input: CreateDraftFromWorkflowVersionInput,
) => {
await mutate({ variables: { input } });
await mutate({
variables: { input },
awaitRefetchQueries: true,
refetchQueries: [
{
query: findManyWorkflowsQuery,
variables: {
id: input.workflowId,
},
},
],
});
};

return {
Expand Down
Loading