Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
Loading