From 8d36bdd42cc548ac6bc34afa89a2b4b829ab1a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Malfait?= Date: Sat, 8 Jul 2023 17:43:34 +0200 Subject: [PATCH] Rename createCommentThreadWithComment --- front/src/generated/graphql.tsx | 28 +++++++++---------- .../RightDrawerCreateCommentThread.tsx | 7 ++--- front/src/modules/comments/services/create.ts | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/front/src/generated/graphql.tsx b/front/src/generated/graphql.tsx index 18e0a5df6b3..3432ee12d2e 100644 --- a/front/src/generated/graphql.tsx +++ b/front/src/generated/graphql.tsx @@ -3031,7 +3031,7 @@ export type CreateCommentMutationVariables = Exact<{ export type CreateCommentMutation = { __typename?: 'Mutation', createOneComment: { __typename?: 'Comment', id: string, createdAt: string, body: string, commentThreadId: string, author: { __typename?: 'User', id: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } } }; -export type CreateCommentThreadWithCommentMutationVariables = Exact<{ +export type CreateCommentThreadMutationVariables = Exact<{ commentThreadId: Scalars['String']; body?: InputMaybe; title?: InputMaybe; @@ -3041,7 +3041,7 @@ export type CreateCommentThreadWithCommentMutationVariables = Exact<{ }>; -export type CreateCommentThreadWithCommentMutation = { __typename?: 'Mutation', createOneCommentThread: { __typename?: 'CommentThread', id: string, createdAt: string, updatedAt: string, authorId: string, commentThreadTargets?: Array<{ __typename?: 'CommentThreadTarget', id: string, createdAt: string, updatedAt: string, commentThreadId: string, commentableType: CommentableType, commentableId: string }> | null, comments?: Array<{ __typename?: 'Comment', id: string, createdAt: string, updatedAt: string, body: string, author: { __typename?: 'User', id: string } }> | null } }; +export type CreateCommentThreadMutation = { __typename?: 'Mutation', createOneCommentThread: { __typename?: 'CommentThread', id: string, createdAt: string, updatedAt: string, authorId: string, commentThreadTargets?: Array<{ __typename?: 'CommentThreadTarget', id: string, createdAt: string, updatedAt: string, commentThreadId: string, commentableType: CommentableType, commentableId: string }> | null, comments?: Array<{ __typename?: 'Comment', id: string, createdAt: string, updatedAt: string, body: string, author: { __typename?: 'User', id: string } }> | null } }; export type GetCommentThreadsByTargetsQueryVariables = Exact<{ commentThreadTargetIds: Array | Scalars['String']; @@ -3576,8 +3576,8 @@ export function useCreateCommentMutation(baseOptions?: Apollo.MutationHookOption export type CreateCommentMutationHookResult = ReturnType; export type CreateCommentMutationResult = Apollo.MutationResult; export type CreateCommentMutationOptions = Apollo.BaseMutationOptions; -export const CreateCommentThreadWithCommentDocument = gql` - mutation CreateCommentThreadWithComment($commentThreadId: String!, $body: String, $title: String, $authorId: String!, $createdAt: DateTime!, $commentThreadTargetArray: [CommentThreadTargetCreateManyCommentThreadInput!]!) { +export const CreateCommentThreadDocument = gql` + mutation CreateCommentThread($commentThreadId: String!, $body: String, $title: String, $authorId: String!, $createdAt: DateTime!, $commentThreadTargetArray: [CommentThreadTargetCreateManyCommentThreadInput!]!) { createOneCommentThread( data: {id: $commentThreadId, createdAt: $createdAt, updatedAt: $createdAt, author: {connect: {id: $authorId}}, body: $body, title: $title, commentThreadTargets: {createMany: {data: $commentThreadTargetArray, skipDuplicates: true}}} ) { @@ -3605,20 +3605,20 @@ export const CreateCommentThreadWithCommentDocument = gql` } } `; -export type CreateCommentThreadWithCommentMutationFn = Apollo.MutationFunction; +export type CreateCommentThreadMutationFn = Apollo.MutationFunction; /** - * __useCreateCommentThreadWithCommentMutation__ + * __useCreateCommentThreadMutation__ * - * To run a mutation, you first call `useCreateCommentThreadWithCommentMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useCreateCommentThreadWithCommentMutation` returns a tuple that includes: + * To run a mutation, you first call `useCreateCommentThreadMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useCreateCommentThreadMutation` returns a tuple that includes: * - A mutate function that you can call at any time to execute the mutation * - An object with fields that represent the current status of the mutation's execution * * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; * * @example - * const [createCommentThreadWithCommentMutation, { data, loading, error }] = useCreateCommentThreadWithCommentMutation({ + * const [createCommentThreadMutation, { data, loading, error }] = useCreateCommentThreadMutation({ * variables: { * commentThreadId: // value for 'commentThreadId' * body: // value for 'body' @@ -3629,13 +3629,13 @@ export type CreateCommentThreadWithCommentMutationFn = Apollo.MutationFunction) { +export function useCreateCommentThreadMutation(baseOptions?: Apollo.MutationHookOptions) { const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(CreateCommentThreadWithCommentDocument, options); + return Apollo.useMutation(CreateCommentThreadDocument, options); } -export type CreateCommentThreadWithCommentMutationHookResult = ReturnType; -export type CreateCommentThreadWithCommentMutationResult = Apollo.MutationResult; -export type CreateCommentThreadWithCommentMutationOptions = Apollo.BaseMutationOptions; +export type CreateCommentThreadMutationHookResult = ReturnType; +export type CreateCommentThreadMutationResult = Apollo.MutationResult; +export type CreateCommentThreadMutationOptions = Apollo.BaseMutationOptions; export const GetCommentThreadsByTargetsDocument = gql` query GetCommentThreadsByTargets($commentThreadTargetIds: [String!]!, $orderBy: [CommentThreadOrderByWithRelationInput!]) { findManyCommentThreads( diff --git a/front/src/modules/comments/components/RightDrawerCreateCommentThread.tsx b/front/src/modules/comments/components/RightDrawerCreateCommentThread.tsx index cdff0f35d7c..d89fe10140f 100644 --- a/front/src/modules/comments/components/RightDrawerCreateCommentThread.tsx +++ b/front/src/modules/comments/components/RightDrawerCreateCommentThread.tsx @@ -16,7 +16,7 @@ import { useOpenRightDrawer } from '@/ui/layout/right-drawer/hooks/useOpenRightD import { logError } from '@/utils/logs/logError'; import { isDefined } from '@/utils/type-guards/isDefined'; import { isNonEmptyString } from '@/utils/type-guards/isNonEmptyString'; -import { useCreateCommentThreadWithCommentMutation } from '~/generated/graphql'; +import { useCreateCommentThreadMutation } from '~/generated/graphql'; import { useOpenCommentThreadRightDrawer } from '../hooks/useOpenCommentThreadRightDrawer'; import { @@ -32,8 +32,7 @@ export function RightDrawerCreateCommentThread() { const [commentableEntityArray] = useRecoilState(commentableEntityArrayState); - const [createCommentThreadWithComment] = - useCreateCommentThreadWithCommentMutation(); + const [CreateCommentThread] = useCreateCommentThreadMutation(); const currentUser = useRecoilValue(currentUserState); @@ -53,7 +52,7 @@ export function RightDrawerCreateCommentThread() { return; } - createCommentThreadWithComment({ + CreateCommentThread({ variables: { authorId: currentUser.id, body: body, diff --git a/front/src/modules/comments/services/create.ts b/front/src/modules/comments/services/create.ts index d7718644fde..567b1c49a3c 100644 --- a/front/src/modules/comments/services/create.ts +++ b/front/src/modules/comments/services/create.ts @@ -33,7 +33,7 @@ export const CREATE_COMMENT = gql` `; export const CREATE_COMMENT_THREAD_WITH_COMMENT = gql` - mutation CreateCommentThreadWithComment( + mutation CreateCommentThread( $commentThreadId: String! $body: String $title: String