You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by jd...@apache.org on 2026/09/30 14:47:43 UTC

(grails-core) 01/06: Cast executeQuery's DetachedCriteria#list result to T in EntityDataFetcher

This is an automated email from the ASF dual-hosted git repository.

jdaugherty pushed a commit to branch refactor/graphql-fetcher
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit d291c02498dc7c12f888bf6c16352c7f7bc0cae6
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Sat Aug 22 21:42:20 2026 -0500

    Cast executeQuery's DetachedCriteria#list result to T in EntityDataFetcher
    
    buildCriteria(environment).list(queryArgs) returns a raw List, which
    was returned directly from a method declared to return T. Compiles
    under CompileStatic only because T is unbounded (erases to Object),
    but the assignment isn't actually type-checked - the same shape
    PaginatedEntityDataFetcher and every other DefaultGormDataFetcher
    subclass already guards against with an explicit (T) cast at the
    return site. Add the same cast here for consistency and to make the
    intent explicit. Covered by the existing EntityDataFetcherSpec
    "test get"/"test pagination" specs, which assert on the returned list.
    
    Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
---
 .../org/grails/gorm/graphql/fetcher/impl/EntityDataFetcher.groovy       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/impl/EntityDataFetcher.groovy b/grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/impl/EntityDataFetcher.groovy
index f283a2c7ea..745551a1fb 100644
--- a/grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/impl/EntityDataFetcher.groovy
+++ b/grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/impl/EntityDataFetcher.groovy
@@ -81,7 +81,7 @@ class EntityDataFetcher<T> extends DefaultGormDataFetcher<T> implements ReadingG
     }
 
     protected T executeQuery(DataFetchingEnvironment environment, Map queryArgs) {
-        buildCriteria(environment).list(queryArgs)
+        (T) buildCriteria(environment).list(queryArgs)
     }
 
     @Override