-
Notifications
You must be signed in to change notification settings - Fork 69
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
getExerciseComment and getChildComments GraphQL queries #2480
Conversation
@HS-90 is attempting to deploy a commit to the c0d3-prod Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## master #2480 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 186 186
Lines 3316 3324 +8
Branches 881 881
=========================================
+ Hits 3316 3324 +8
|
return prisma.exerciseComment.findMany({ | ||
where: { parentId: null, exerciseId }, | ||
include: { | ||
replies: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will only include the exercise comment replies and not the replies nested replies like
// Main exercise comment
{
replies: [
{
// ...props -> It won't have this, right?
replies: []
}
// reply2...etc
]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right it will retrieve all the 'main' comments and one nested layer of replies below that, then we use the getChildComments
query to get the nested replies beyond that level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! In a following PR, we can create their query files which will help in creating their hooks.
Thanks. Will do that in the next PR |
Description: relates to #2400
This PR adds two GraphQL resolvers for getting exercise comments(filtered by exerciseId), and getting child comments(filtered by parentId). When implemented on the frontend, the
getExerciseComment
will get any main comments, and it's replies. Any nested replies beyond the first reply to main comments will be retrieved withgetChildComments
.To test:
First we need to add comments
mutation AddExerciseComment{ addExerciseComment(exerciseId:1, content:"Cool"){ id exerciseId content } }
mutation AddExerciseComment{ addExerciseComment(exerciseId:1, parentId: 1, content:" Really Really COOL!"){ id exerciseId parentId content } }
mutation AddExerciseComment{ addExerciseComment(exerciseId:1, parentId: 1, content:"Cool bro"){ id exerciseId parentId content } }
Getting Exercise Comments
3. Write a query to get all main comments with ExerciseId 1:
query GetExerciseComments{ getExerciseComments(exerciseId:1){ id createdAt exerciseId parentId content replies{ id createdAt content } } }
It should return something like this:
Getting Child Comments
4. Write a query to get all
exerciseComment
with parentId of1
:query GetChildComments{ getChildComments(parentId:1){ id createdAt exerciseId parentId content } }
It should return something like this: