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

Add getChildComments and getExerciseComments query files and hooks #2485

Merged
merged 3 commits into from
Nov 3, 2022
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
306 changes: 306 additions & 0 deletions graphql/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ export type Query = {
challenges: Array<Challenge>
exerciseSubmissions: Array<ExerciseSubmission>
exercises: Array<Exercise>
getChildComments: Array<ExerciseComment>
getExerciseComments: Array<ExerciseComment>
getLessonMentors?: Maybe<Array<Maybe<User>>>
getPreviousSubmissions?: Maybe<Array<Submission>>
isTokenValid: Scalars['Boolean']
Expand All @@ -370,6 +372,14 @@ export type QueryChallengesArgs = {
lessonId?: InputMaybe<Scalars['Int']>
}

export type QueryGetChildCommentsArgs = {
parentId: Scalars['Int']
}

export type QueryGetExerciseCommentsArgs = {
exerciseId: Scalars['Int']
}

export type QueryGetLessonMentorsArgs = {
lessonId: Scalars['Int']
}
Expand Down Expand Up @@ -1412,6 +1422,66 @@ export type AddExerciseCommentMutation = {
}
}

export type ChildCommentsQueryVariables = Exact<{
parentId: Scalars['Int']
}>

export type ChildCommentsQuery = {
__typename?: 'Query'
getChildComments: Array<{
__typename?: 'ExerciseComment'
id: number
exerciseId: number
authorId: number
content: string
userPic?: string | null
createdAt: string
updatedAt?: string | null
author: { __typename?: 'User'; username: string }
replies?: Array<{
__typename?: 'ExerciseComment'
id: number
exerciseId: number
authorId: number
content: string
userPic?: string | null
createdAt: string
updatedAt?: string | null
author: { __typename?: 'User'; username: string }
} | null> | null
}>
}

export type ExerciseCommentsQueryVariables = Exact<{
exerciseId: Scalars['Int']
}>

export type ExerciseCommentsQuery = {
__typename?: 'Query'
getExerciseComments: Array<{
__typename?: 'ExerciseComment'
id: number
exerciseId: number
authorId: number
content: string
userPic?: string | null
createdAt: string
updatedAt?: string | null
author: { __typename?: 'User'; username: string }
replies?: Array<{
__typename?: 'ExerciseComment'
id: number
exerciseId: number
authorId: number
content: string
userPic?: string | null
createdAt: string
updatedAt?: string | null
author: { __typename?: 'User'; username: string }
} | null> | null
}>
}

export type WithIndex<TObject> = TObject & Record<string, any>
export type ResolversObject<TObject> = WithIndex<TObject>

Expand Down Expand Up @@ -1982,6 +2052,18 @@ export type QueryResolvers<
ParentType,
ContextType
>
getChildComments?: Resolver<
Array<ResolversTypes['ExerciseComment']>,
ParentType,
ContextType,
RequireFields<QueryGetChildCommentsArgs, 'parentId'>
>
getExerciseComments?: Resolver<
Array<ResolversTypes['ExerciseComment']>,
ParentType,
ContextType,
RequireFields<QueryGetExerciseCommentsArgs, 'exerciseId'>
>
getLessonMentors?: Resolver<
Maybe<Array<Maybe<ResolversTypes['User']>>>,
ParentType,
Expand Down Expand Up @@ -6047,6 +6129,226 @@ export type AddExerciseCommentMutationOptions = Apollo.BaseMutationOptions<
AddExerciseCommentMutation,
AddExerciseCommentMutationVariables
>
export const ChildCommentsDocument = gql`
query childComments($parentId: Int!) {
getChildComments(parentId: $parentId) {
id
exerciseId
authorId
content
userPic
createdAt
updatedAt
author {
username
}
replies {
id
exerciseId
authorId
content
userPic
createdAt
updatedAt
author {
username
}
}
}
}
`
export type ChildCommentsProps<
TChildProps = {},
TDataName extends string = 'data'
> = {
[key in TDataName]: ApolloReactHoc.DataValue<
ChildCommentsQuery,
ChildCommentsQueryVariables
>
} & TChildProps
export function withChildComments<
TProps,
TChildProps = {},
TDataName extends string = 'data'
>(
operationOptions?: ApolloReactHoc.OperationOption<
TProps,
ChildCommentsQuery,
ChildCommentsQueryVariables,
ChildCommentsProps<TChildProps, TDataName>
>
) {
return ApolloReactHoc.withQuery<
TProps,
ChildCommentsQuery,
ChildCommentsQueryVariables,
ChildCommentsProps<TChildProps, TDataName>
>(ChildCommentsDocument, {
alias: 'childComments',
...operationOptions
})
}

/**
* __useChildCommentsQuery__
*
* To run a query within a React component, call `useChildCommentsQuery` and pass it any options that fit your needs.
* When your component renders, `useChildCommentsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useChildCommentsQuery({
* variables: {
* parentId: // value for 'parentId'
* },
* });
*/
export function useChildCommentsQuery(
baseOptions: Apollo.QueryHookOptions<
ChildCommentsQuery,
ChildCommentsQueryVariables
>
) {
const options = { ...defaultOptions, ...baseOptions }
return Apollo.useQuery<ChildCommentsQuery, ChildCommentsQueryVariables>(
ChildCommentsDocument,
options
)
}
export function useChildCommentsLazyQuery(
baseOptions?: Apollo.LazyQueryHookOptions<
ChildCommentsQuery,
ChildCommentsQueryVariables
>
) {
const options = { ...defaultOptions, ...baseOptions }
return Apollo.useLazyQuery<ChildCommentsQuery, ChildCommentsQueryVariables>(
ChildCommentsDocument,
options
)
}
export type ChildCommentsQueryHookResult = ReturnType<
typeof useChildCommentsQuery
>
export type ChildCommentsLazyQueryHookResult = ReturnType<
typeof useChildCommentsLazyQuery
>
export type ChildCommentsQueryResult = Apollo.QueryResult<
ChildCommentsQuery,
ChildCommentsQueryVariables
>
export const ExerciseCommentsDocument = gql`
query exerciseComments($exerciseId: Int!) {
getExerciseComments(exerciseId: $exerciseId) {
id
exerciseId
authorId
content
userPic
createdAt
updatedAt
author {
username
}
replies {
id
exerciseId
authorId
content
userPic
createdAt
updatedAt
author {
username
}
}
}
}
`
export type ExerciseCommentsProps<
TChildProps = {},
TDataName extends string = 'data'
> = {
[key in TDataName]: ApolloReactHoc.DataValue<
ExerciseCommentsQuery,
ExerciseCommentsQueryVariables
>
} & TChildProps
export function withExerciseComments<
TProps,
TChildProps = {},
TDataName extends string = 'data'
>(
operationOptions?: ApolloReactHoc.OperationOption<
TProps,
ExerciseCommentsQuery,
ExerciseCommentsQueryVariables,
ExerciseCommentsProps<TChildProps, TDataName>
>
) {
return ApolloReactHoc.withQuery<
TProps,
ExerciseCommentsQuery,
ExerciseCommentsQueryVariables,
ExerciseCommentsProps<TChildProps, TDataName>
>(ExerciseCommentsDocument, {
alias: 'exerciseComments',
...operationOptions
})
}

/**
* __useExerciseCommentsQuery__
*
* To run a query within a React component, call `useExerciseCommentsQuery` and pass it any options that fit your needs.
* When your component renders, `useExerciseCommentsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useExerciseCommentsQuery({
* variables: {
* exerciseId: // value for 'exerciseId'
* },
* });
*/
export function useExerciseCommentsQuery(
baseOptions: Apollo.QueryHookOptions<
ExerciseCommentsQuery,
ExerciseCommentsQueryVariables
>
) {
const options = { ...defaultOptions, ...baseOptions }
return Apollo.useQuery<ExerciseCommentsQuery, ExerciseCommentsQueryVariables>(
ExerciseCommentsDocument,
options
)
}
export function useExerciseCommentsLazyQuery(
baseOptions?: Apollo.LazyQueryHookOptions<
ExerciseCommentsQuery,
ExerciseCommentsQueryVariables
>
) {
const options = { ...defaultOptions, ...baseOptions }
return Apollo.useLazyQuery<
ExerciseCommentsQuery,
ExerciseCommentsQueryVariables
>(ExerciseCommentsDocument, options)
}
export type ExerciseCommentsQueryHookResult = ReturnType<
typeof useExerciseCommentsQuery
>
export type ExerciseCommentsLazyQueryHookResult = ReturnType<
typeof useExerciseCommentsLazyQuery
>
export type ExerciseCommentsQueryResult = Apollo.QueryResult<
ExerciseCommentsQuery,
ExerciseCommentsQueryVariables
>
export type AlertKeySpecifier = (
| 'id'
| 'text'
Expand Down Expand Up @@ -6301,6 +6603,8 @@ export type QueryKeySpecifier = (
| 'challenges'
| 'exerciseSubmissions'
| 'exercises'
| 'getChildComments'
| 'getExerciseComments'
| 'getLessonMentors'
| 'getPreviousSubmissions'
| 'isTokenValid'
Expand All @@ -6317,6 +6621,8 @@ export type QueryFieldPolicy = {
challenges?: FieldPolicy<any> | FieldReadFunction<any>
exerciseSubmissions?: FieldPolicy<any> | FieldReadFunction<any>
exercises?: FieldPolicy<any> | FieldReadFunction<any>
getChildComments?: FieldPolicy<any> | FieldReadFunction<any>
getExerciseComments?: FieldPolicy<any> | FieldReadFunction<any>
getLessonMentors?: FieldPolicy<any> | FieldReadFunction<any>
getPreviousSubmissions?: FieldPolicy<any> | FieldReadFunction<any>
isTokenValid?: FieldPolicy<any> | FieldReadFunction<any>
Expand Down
31 changes: 31 additions & 0 deletions graphql/queries/getChildComments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { gql } from '@apollo/client'

const CHILD_COMMENTS = gql`
query childComments($parentId: Int!) {
getChildComments(parentId: $parentId) {
id
exerciseId
authorId
content
userPic
createdAt
updatedAt
author {
username
}
replies {
id
exerciseId
authorId
content
userPic
createdAt
updatedAt
author {
username
}
}
}
}
`
export default CHILD_COMMENTS
Loading