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

feature: populate game room with questions #293

Merged
merged 11 commits into from
Mar 15, 2022

Conversation

dtnguyen22
Copy link
Collaborator

@dtnguyen22 dtnguyen22 commented Mar 13, 2022

Related issue

Fixes #248

Type of Change

  • Feat: Change which adds functionality/new feature
  • Fix: Change which fixes an issue
  • Refactor: Change which improves the structure of the code
  • Docs: Change which improves documentation

Description

Notes:

  1. I can see there will be a lot of conflicts since Thanh is working on gameRoom datasource as well, I'll take care of it after conflicts are resolved
  2. createGameRoom() currently allows to create another gameRoom and overwrite the gameRoomID in a chatRoom, if there is any restriction please tell me. users are allowed to play the game only 1 time
  • Add questionAPI and query to test getQuestion()
    image

  • Pupulate gameRoom with 10 questions from questionAPI.getQuestion()
    image

  • Add createGameRoom mutation and getGameRoomById for manually testing.
    image
    image

Screenshot

First, we have a chatRoom that has no gameRoom
image

Grab the _id (62114891f032396dff000000) and try to create a new gameRoom with createGameRoom mutation
-> If the muta creates the gameRoom successfully, it will return the gameRoom id
image

Otherwise throws error
image

Use the getGameRoomById query to get the gameRoom we have just created
image

Double check the gameRoom in mongo express => everything matches
image

Also the chatRoom
image

Testing

Has this pull request been tested?
Yes

Please describe shortly how you tested it:
please refer to the screenshots

Note

The title of your PR should follow this format: [Type](area): Title

@vercel
Copy link

vercel bot commented Mar 13, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tuanthanh2067/seeksi/ALUvcYcmRoVGgrth47X52rikeDdR
✅ Preview: https://seeksi-git-feature-248-populate-game-room-tuanthanh2067.vercel.app

@oliver-pham oliver-pham changed the title Feature/248 populate game room feature: populate game room with questions Mar 13, 2022
Copy link
Owner

@tuanthanh2067 tuanthanh2067 left a comment

Choose a reason for hiding this comment

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

I've merged my PR, can you please get new codes and update your code accordingly.

Another thing is that we don't have query to get questions but we will set questions to a game room. And then we will have a query to get the game room, which we have another issue for that.

@dtnguyen22
Copy link
Collaborator Author

yes I merged the latest PR and updated the codes in the last two commits

backend/src/graphql/Question/resolvers.js Outdated Show resolved Hide resolved
backend/src/graphql/Question/queries.js Outdated Show resolved Hide resolved
backend/src/graphql/GameRoom/resolvers.js Outdated Show resolved Hide resolved
backend/src/graphql/GameRoom/resolvers.js Outdated Show resolved Hide resolved
backend/src/graphql/GameRoom/resolvers.js Show resolved Hide resolved
Comment on lines 38 to 42
const questions = await this.getQuestion();
const gameRoom = new GameRoom({
_id,
answers,
questions,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you save the Mongo Object ID of the questions only? I think it's specified in the schema.

const gameRoom = new Schema({
questions: {
type: [Schema.Types.ObjectId],
ref: "Questions",
},
answers: [gameAnswerSchema],
});

Then, if we need to return the questions, we only need to populate() them. This should be resolved in #295 if I'm not mistaken.

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah sorry about my mistake earlier, we will store Id and then I'll populate it later when I get game room

Copy link
Collaborator

@oliver-pham oliver-pham left a comment

Choose a reason for hiding this comment

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

Awesome! 💯

@dtnguyen22 dtnguyen22 merged commit 02eb02e into main Mar 15, 2022
@dtnguyen22 dtnguyen22 deleted the feature/248-populate-game-room branch March 15, 2022 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Populate questions for a game room
3 participants