Repository navigation
Write once, check by the rows changed, and tidy the shared layers - #48
Merged
Merged
Conversation
Carries the shared changes from CleanMinimalApi. Mutations now take one input and return a payload holding the result or a ValidationError or NotFoundError. updateReview returns the updated review instead of a Boolean and deleteReview returns the id it deleted. Queries keep the VALIDATION and NOT_FOUND codes. Version is now VersionInfo.
Contributor
Build Pipeline✅ Ready to merge. Every stage passed.
Commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updating or deleting a review no longer checks that the review exists before it writes. The write goes first, and if no rows changed the handler throws not found. That's one trip to the database instead of two, and it closes the gap where another request could slip in between the check and the write. Update now returns the changed review from Application.
The database gets a few sensible defaults in one migration (
AddCollationsAndIndexes):While I was in there, some tidy-ups:
[ForeignKey]and[Required]attributes that repeated the fluent configurationPage<T>.Itemsis now anIReadOnlyList<T>MovieReviewsDatabase, so its connection gets closedvirtualis on every repository methodVersionis nowVersionInfo, so it stops tripping overSystem.Version, and its handler can be testedThe shared layers are the same as LeanMeanCleanApps/CleanMinimalApi#67, with the name swapped.
The GraphQL side picks up Hot Chocolate's mutation conventions. Each mutation takes one
inputand returns a payload, and validation and not found failures come back as typed errors in the payload (ValidationErrorwith the failing fields,NotFoundError) instead of only as error codes inerrors.deleteReviewreturnsreviewId. The input types are generated now, so the hand-writtenInputsfolder is gone, and the schema snapshot is updated.This one changes the schema, so any client that calls the mutations needs updating. Queries are untouched.
The
data-access-ef-core,database-migrations,errors-and-exceptions,paging,unit-tests,test-design,api-conventionsandexpose-a-use-caseskills now match the code.Type of change
Shared layers
Checklist
dotnet buildanddotnet testpass locally with no warnings..agents/skills.