You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by ja...@apache.org on 2026/05/29 03:07:36 UTC
(grails-core) branch fix/graphql-delete-failonerror created (now c7f4064653)
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a change to branch fix/graphql-delete-failonerror
in repository https://gitbox.apache.org/repos/asf/grails-core.git
at c7f4064653 Fix ignored failOnError argument in DeleteEntityDataFetcher
This branch includes the following new commits:
new c7f4064653 Fix ignored failOnError argument in DeleteEntityDataFetcher
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(grails-core) 01/01: Fix ignored failOnError argument in DeleteEntityDataFetcher
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch fix/graphql-delete-failonerror
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit c7f4064653d372eed0bc3d05ffc20c0801b0362e
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Thu May 28 23:07:22 2026 -0400
Fix ignored failOnError argument in DeleteEntityDataFetcher
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
---
.../graphql/fetcher/impl/DeleteEntityDataFetcher.groovy | 2 +-
.../fetcher/impl/DeleteEntityDataFetcherSpec.groovy | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcher.groovy b/grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcher.groovy
index 65a80fac38..56559e4d39 100644
--- a/grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcher.groovy
+++ b/grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcher.groovy
@@ -48,7 +48,7 @@ class DeleteEntityDataFetcher<T> extends DefaultGormDataFetcher<T> implements De
}
protected void deleteInstance(GormEntity instance) {
- instance.delete(failOnError: true)
+ instance.delete(flush: true)
}
@Override
diff --git a/grails-data-graphql/core/src/test/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcherSpec.groovy b/grails-data-graphql/core/src/test/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcherSpec.groovy
index 12d686ce2b..99e2e4b895 100644
--- a/grails-data-graphql/core/src/test/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcherSpec.groovy
+++ b/grails-data-graphql/core/src/test/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcherSpec.groovy
@@ -21,6 +21,7 @@ package org.grails.gorm.graphql.fetcher.impl
import grails.gorm.transactions.Transactional
import graphql.schema.DataFetchingEnvironment
+import org.grails.datastore.gorm.GormEntity
import org.grails.gorm.graphql.HibernateSpec
import org.grails.gorm.graphql.domain.general.toone.One
import org.grails.gorm.graphql.fetcher.GraphQLDataFetcherType
@@ -76,6 +77,19 @@ class DeleteEntityDataFetcherSpec extends HibernateSpec {
1 * responseHandler.createResponse(env, false, _ as NullPointerException)
}
+ void "test deleteInstance flushes the delete and does not pass the ignored failOnError argument"() {
+ given:
+ DeleteEntityDataFetcher fetcher = new DeleteEntityDataFetcher<>(mappingContext.getPersistentEntity(One.name))
+ GormEntity instance = Mock(GormEntity)
+
+ when:
+ fetcher.deleteInstance(instance)
+
+ then: 'the delete is flushed so database failures surface, and failOnError (ignored by delete) is not used'
+ 1 * instance.delete([flush: true])
+ 0 * instance.delete([failOnError: true])
+ }
+
void "test supports"() {
when:
DeleteEntityDataFetcher fetcher = new DeleteEntityDataFetcher<>(mappingContext.getPersistentEntity(One.name))