Fix ignored failOnError argument in DeleteEntityDataFetcher#15692
Open
jamesfredley wants to merge 2 commits into
Open
Fix ignored failOnError argument in DeleteEntityDataFetcher#15692jamesfredley wants to merge 2 commits into
jamesfredley wants to merge 2 commits into
Conversation
GORM's delete(Map) only honors the flush parameter, so the failOnError: true argument passed in deleteInstance() was silently ignored. Switch to delete(flush: true) so the delete executes immediately and any failure surfaces through the data fetcher's response handler. Flagged during review of #15599. Assisted-by: claude-code:claude-4.8-opus
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes DeleteEntityDataFetcher.deleteInstance() to use a GORM delete option that is actually honored, ensuring delete failures surface immediately and are handled by the existing try/catch response creation logic.
Changes:
- Updated
DeleteEntityDataFetcher.deleteInstance()fromdelete(failOnError: true)todelete(flush: true)so the delete is executed/flushed immediately. - Added a Spock interaction test to assert the fetcher calls
delete(flush: true)and does not pass the ignoredfailOnErrorargument.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcher.groovy | Uses flush: true for deletes so failures surface at the delete point and can be captured by existing error handling. |
| grails-data-graphql/core/src/test/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcherSpec.groovy | Adds an interaction test locking in the delete(flush: true) call and preventing regression to the ignored failOnError argument. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
DeleteEntityDataFetcher.deleteInstance()calledinstance.delete(failOnError: true), but GORM'sdelete(Map)only honors theflushparameter - thefailOnErrorargument is silently ignored. As a result the data fetcher gained no error-handling benefit from it.This switches the call to
instance.delete(flush: true), so the delete executes immediately and any failure (e.g. constraint violation, optimistic locking) is raised at that point and surfaces through the fetcher's existing try/catch toresponseHandler.createResponse(env, false, exception). This matches theflush: truedelete guidance documented in #15599.Changes
DeleteEntityDataFetcher:delete(failOnError: true)todelete(flush: true).DeleteEntityDataFetcherSpec: added an interaction test assertingdeleteInstancecallsdelete(flush: true)and no longer passes the ignoredfailOnErrorargument.Testing
All pass, including the existing happy-path / invalid-id cases and the
SoftDeleteEntityDataFetcher(which overridesdeleteInstance) regression check.Flagged during review of #15599.