From 209e64c95da099a2769c6246e31f98f22e5d6e78 Mon Sep 17 00:00:00 2001 From: Flacial Date: Wed, 22 Jun 2022 07:38:35 +0400 Subject: [PATCH] fix: Generate useDeleteExercise hook --- graphql/index.tsx | 110 ++++++++++++++++++++++++++++++ graphql/queries/deleteExercise.ts | 11 +++ graphql/typeDefs.ts | 4 ++ 3 files changed, 125 insertions(+) create mode 100644 graphql/queries/deleteExercise.ts diff --git a/graphql/index.tsx b/graphql/index.tsx index fd2bee4df..45b6d0fa4 100644 --- a/graphql/index.tsx +++ b/graphql/index.tsx @@ -78,6 +78,10 @@ export type Exercise = { author: User description: Scalars['String'] explanation?: Maybe + flagReason?: Maybe + flaggedAt?: Maybe + flaggedBy?: Maybe + flaggedById?: Maybe id: Scalars['Int'] module: Module testStr?: Maybe @@ -589,6 +593,15 @@ export type DeleteCommentMutation = { deleteComment?: { __typename?: 'Comment'; id: number } | null } +export type DeleteExerciseMutationVariables = Exact<{ + id: Scalars['Int'] +}> + +export type DeleteExerciseMutation = { + __typename?: 'Mutation' + deleteExercise: { __typename?: 'Exercise'; id: number } +} + export type DeleteModuleMutationVariables = Exact<{ id: Scalars['Int'] }> @@ -1370,6 +1383,14 @@ export type ExerciseResolvers< ParentType, ContextType > + flagReason?: Resolver< + Maybe, + ParentType, + ContextType + > + flaggedAt?: Resolver, ParentType, ContextType> + flaggedBy?: Resolver, ParentType, ContextType> + flaggedById?: Resolver, ParentType, ContextType> id?: Resolver module?: Resolver testStr?: Resolver, ParentType, ContextType> @@ -2760,6 +2781,87 @@ export type DeleteCommentMutationOptions = Apollo.BaseMutationOptions< DeleteCommentMutation, DeleteCommentMutationVariables > +export const DeleteExerciseDocument = gql` + mutation deleteExercise($id: Int!) { + deleteExercise(id: $id) { + id + } + } +` +export type DeleteExerciseMutationFn = Apollo.MutationFunction< + DeleteExerciseMutation, + DeleteExerciseMutationVariables +> +export type DeleteExerciseProps< + TChildProps = {}, + TDataName extends string = 'mutate' +> = { + [key in TDataName]: Apollo.MutationFunction< + DeleteExerciseMutation, + DeleteExerciseMutationVariables + > +} & TChildProps +export function withDeleteExercise< + TProps, + TChildProps = {}, + TDataName extends string = 'mutate' +>( + operationOptions?: ApolloReactHoc.OperationOption< + TProps, + DeleteExerciseMutation, + DeleteExerciseMutationVariables, + DeleteExerciseProps + > +) { + return ApolloReactHoc.withMutation< + TProps, + DeleteExerciseMutation, + DeleteExerciseMutationVariables, + DeleteExerciseProps + >(DeleteExerciseDocument, { + alias: 'deleteExercise', + ...operationOptions + }) +} + +/** + * __useDeleteExerciseMutation__ + * + * To run a mutation, you first call `useDeleteExerciseMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useDeleteExerciseMutation` 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 [deleteExerciseMutation, { data, loading, error }] = useDeleteExerciseMutation({ + * variables: { + * id: // value for 'id' + * }, + * }); + */ +export function useDeleteExerciseMutation( + baseOptions?: Apollo.MutationHookOptions< + DeleteExerciseMutation, + DeleteExerciseMutationVariables + > +) { + const options = { ...defaultOptions, ...baseOptions } + return Apollo.useMutation< + DeleteExerciseMutation, + DeleteExerciseMutationVariables + >(DeleteExerciseDocument, options) +} +export type DeleteExerciseMutationHookResult = ReturnType< + typeof useDeleteExerciseMutation +> +export type DeleteExerciseMutationResult = + Apollo.MutationResult +export type DeleteExerciseMutationOptions = Apollo.BaseMutationOptions< + DeleteExerciseMutation, + DeleteExerciseMutationVariables +> export const DeleteModuleDocument = gql` mutation deleteModule($id: Int!) { deleteModule(id: $id) { @@ -4653,6 +4755,10 @@ export type ExerciseKeySpecifier = ( | 'author' | 'description' | 'explanation' + | 'flagReason' + | 'flaggedAt' + | 'flaggedBy' + | 'flaggedById' | 'id' | 'module' | 'testStr' @@ -4663,6 +4769,10 @@ export type ExerciseFieldPolicy = { author?: FieldPolicy | FieldReadFunction description?: FieldPolicy | FieldReadFunction explanation?: FieldPolicy | FieldReadFunction + flagReason?: FieldPolicy | FieldReadFunction + flaggedAt?: FieldPolicy | FieldReadFunction + flaggedBy?: FieldPolicy | FieldReadFunction + flaggedById?: FieldPolicy | FieldReadFunction id?: FieldPolicy | FieldReadFunction module?: FieldPolicy | FieldReadFunction testStr?: FieldPolicy | FieldReadFunction diff --git a/graphql/queries/deleteExercise.ts b/graphql/queries/deleteExercise.ts new file mode 100644 index 000000000..32ba6a085 --- /dev/null +++ b/graphql/queries/deleteExercise.ts @@ -0,0 +1,11 @@ +import { gql } from '@apollo/client' + +const DELETE_EXERCISE = gql` + mutation deleteExercise($id: Int!) { + deleteExercise(id: $id) { + id + } + } +` + +export default DELETE_EXERCISE diff --git a/graphql/typeDefs.ts b/graphql/typeDefs.ts index 22a633a03..c6cce457a 100644 --- a/graphql/typeDefs.ts +++ b/graphql/typeDefs.ts @@ -257,5 +257,9 @@ export default gql` answer: String! testStr: String explanation: String + flaggedAt: String + flagReason: String + flaggedBy: User + flaggedById: Int } `