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

feat: batch findUniqueOrThrow for getting tests feedback (co-authored by @hayes) #4019

Merged
merged 3 commits into from
Jun 6, 2023

Conversation

miguelff
Copy link
Contributor

@miguelff miguelff commented Jun 5, 2023

Supersedes #4014 so we can take it from here. Thank you @hayes, You will get credit in the git history for this work.

@miguelff miguelff requested a review from a team as a code owner June 5, 2023 15:00
@miguelff miguelff changed the title tmp: hayes tmp: hayes's patch to batch findUniqueOrThrow for getting tests feedback. Will close. Jun 5, 2023
@miguelff miguelff marked this pull request as draft June 5, 2023 15:01
@codspeed-hq
Copy link

codspeed-hq bot commented Jun 5, 2023

CodSpeed Performance Report

Merging #4019 hayes/main (39c063f) will not alter performances.

Summary

🔥 0 improvements
❌ 0 regressions
✅ 11 untouched benchmarks

🆕 0 new benchmarks
⁉️ 0 dropped benchmarks

@miguelff miguelff changed the title tmp: hayes's patch to batch findUniqueOrThrow for getting tests feedback. Will close. feat: batch findUniqueOrThrow for getting tests feedback (co-authored by @hayes) Jun 5, 2023
@miguelff miguelff requested a review from Weakky June 5, 2023 15:56
@miguelff miguelff marked this pull request as ready for review June 5, 2023 15:57
@Jolg42
Copy link
Member

Jolg42 commented Jun 5, 2023

Note: related to
prisma/prisma#18838
prisma/prisma#16625

@miguelff miguelff added this to the 4.16.0 milestone Jun 5, 2023
Copy link
Member

@Weakky Weakky left a comment

Choose a reason for hiding this comment

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

Looks good 👍

Comment on lines +175 to +180
None if throw_on_empty => responses.insert_error(GQLError::from_user_facing_error(
user_facing_errors::query_engine::RecordRequiredButNotFound {
cause: "Expected a record, found none.".to_owned(),
}
.into(),
)),
Copy link
Member

Choose a reason for hiding this comment

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

A bit hacky but that should do the work 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed hacky, I tried to find some refactoring opportunity to consolidate this logic and the logic in the query interpreter that renders *OrThrow errors, but found it less clear than actually repeating myself.

Comment on lines +175 to +179
if self.throw_on_empty() {
format!("findUnique{}OrThrow", self.name)
} else {
format!("findUnique{}", self.name)
}
Copy link
Member

Choose a reason for hiding this comment

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

Would be great if we could use the schema::IdentifierType enum here, but we can't really because we don't have access to the model. We could make that work by using a dyn trait, but it's not worth it atm. Just some out loud thoughts.

@miguelff miguelff merged commit e3e1da1 into main Jun 6, 2023
29 checks passed
@miguelff miguelff deleted the hayes/main branch June 6, 2023 10:18
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.

None yet

4 participants