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

MCR-4449: Rate create rate question response api #2824

Merged
merged 5 commits into from
Oct 10, 2024

Conversation

JasonLin0991
Copy link
Contributor

@JasonLin0991 JasonLin0991 commented Oct 9, 2024

Summary

MCR-4449

  • insertRateQuestionResponse Postgres function
  • createRateQuestionResponse mutation and resolver

Related issues

Screenshots

Test cases covered

createRateQuestionResponse.test.ts

  • 'returns question response data'
  • 'returns an error when attempting to create a response for a question that does not exist'
  • 'returns an error if a cms user attempts to create a response for a rate question'

QA guidance

@JasonLin0991 JasonLin0991 marked this pull request as ready for review October 9, 2024 22:44
@JasonLin0991 JasonLin0991 changed the title MCR-4449: Q&A by rate create question response api MCR-4449: Rate create rate question response api Oct 10, 2024
@@ -701,7 +705,7 @@ type CreateRateQuestionPayload {
# question: Question!
#}

input CreateContractQuestionResponseInput {
input CreateQuestionResponseInput {
Copy link
Contributor

@haworku haworku Oct 10, 2024

Choose a reason for hiding this comment

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

Can you clarify in the naming or the comment this is a generic type it works for both rate and question responses. I think its worth clarifying because everything else seems to have distinct types (either contract or rate) for this API

Copy link
Contributor

@haworku haworku left a comment

Choose a reason for hiding this comment

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

This looks good - lets merge through and start to build some UI to test

@@ -39,15 +42,14 @@ export async function insertContractQuestionResponse(
include: questionInclude,
})

return questionPrismaToDomainType(result)
return contractQuestionPrismaToDomainType(result)
} catch (e) {
// Return a NotFoundError if prisma fails on the primary key constraint
// An operation failed because it depends on one or more records
// that were required but not found.
if (e.code === 'P2025') {
Copy link
Contributor

@haworku haworku Oct 10, 2024

Choose a reason for hiding this comment

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

I said this to @macrael in an earlier PR, it seems brittle to hardcode these error codes in random postgres functions we should be using helper functions. seems like this is isMissingRelatedRecord or something like that because record to update doesnt exist

@JasonLin0991 JasonLin0991 merged commit ea1997e into main Oct 10, 2024
28 checks passed
@JasonLin0991 JasonLin0991 deleted the jl-mcr-4449-qa-rate-response-api branch October 10, 2024 16:01
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.

2 participants