Repository navigation
refactor(grails-data-graphql): clean up the fetcher package - #16203
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 8.1.x #16203 +/- ##
===================================================
+ Coverage 32.7869% 59.2479% +26.4610%
- Complexity 563 25135 +24572
===================================================
Files 84 2215 +2131
Lines 4941 108863 +103922
Branches 864 19798 +18934
===================================================
+ Hits 1620 64499 +62879
- Misses 3061 35430 +32369
- Partials 260 8934 +8674 🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
36b7716 to
df7efef
Compare
2865d10 to
beb5efa
Compare
…tcher 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 <noreply@anthropic.com>
…kers CustomInterceptorInvoker#invoke and ProvidedInterceptorInvoker#invoke were identical 9-line fragments: resolve the operation name, run the subclass-specific invocation, log when it returns false, return the result. Extract the shared name/log/return steps into a logIfPrevented(name, result) template method on the common InterceptorInvoker base (which now carries the @Slf4j/@CompileStatic annotations instead of each sibling declaring its own logger), and have both invoke() overrides call it. Behavior is unchanged; the existing Query/Mutation/CustomQuery/CustomMutation InterceptorInvoker specs already cover both the allowed and prevented-by-interceptor branches. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…Invoker getFields() has been deprecated in graphql-java since 2018-12-20 in favor of getMergedField(). InterceptorInvoker#getName() used environment.fields[0].name (with an empty-list guard) purely to grab the name of the current field; MergedField#getName() returns exactly the same value (the single field's name), so swap to getMergedField() with a null guard instead. Updated QueryInterceptorInvokerSpec/MutationInterceptorInvokerSpec and InterceptingDataFetcherSpec, which stubbed the now-unused getFields(), to stub getMergedField() instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- associations was declared Map<String, Association> (raw) but assigned from EntityFetchOptions#getAssociations(), which returns Map<String, Association<?>> since the earlier raw-type cleanup. Parameterize the field to match. - initializeEntity(PersistentEntity) never used its parameter - the entity it needs is already captured on `this.entity` by the time the constructor calls it. Drop the redundant parameter. - withTransaction declared a blank `datastore` local reassigned across an if/else, the same "assign-in-every-branch" shape flagged elsewhere in this cleanup. Extract the branch into a resolveDatastore() helper that returns directly from each branch. Behavior is unchanged; covered by the existing DefaultGormDataFetcherSpec join-property tests plus every subclass's "test get" spec, which all exercise withTransaction/resolveDatastore. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ildcard IntelliJ flags Map<String, Association<?>> with "Type parameter '?' is not in its bound; should extend Property" since Association<T extends Property>. Writing the bound out explicitly (Association<? extends Property>) looks like the obvious fix, but Groovy's static type checker - unlike javac - treats the bounded and unbounded wildcard forms as distinct types, so initializeEntity()'s `this.associations = this.entityFetchOptions.associations` (which returns Map<String, Association<?>>) fails to compile against it. Keep the unbounded form and record why, the same treatment given to EntityFetchOptions' raw List<Selection> earlier in this cleanup. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
A response handler failure on the success path must surface as a GraphQL error rather than be reported as a failed delete, because by that point the instance has already been removed.
|
Rebased onto Moving The original structure is kept and a comment now documents why the response must be built outside the |
beb5efa to
b048d0a
Compare
Summary
Follows #16201 (merged). Rebased onto
8.1.x. Fixes a series of IntelliJ-flagged issues inorg.grails.gorm.graphql.fetcher.*:DeleteEntityDataFetcher/EntityDataFetcher: simplified branch-per-response construction and added a missing(T)cast onexecuteQuery'sDetachedCriteria#listresult, matching the cast convention every sibling fetcher already uses.CustomInterceptorInvoker/ProvidedInterceptorInvoker: deduplicated an identical 9-line "resolve name → invoke → log if prevented → return" fragment into a sharedlogIfPreventedmethod onInterceptorInvoker.InterceptorInvoker: replaced deprecatedDataFetchingEnvironment#getFields()withgetMergedField().DefaultGormDataFetcher: fixed a type mismatch (Map<String, Association>→Map<String, Association<?>>... with a documented reason it can't be fully parameterized under Groovy's static type checker), dropped an unused constructor parameter, and extractedresolveDatastore()to eliminate an ambiguous "might not be assigned" local variable.Test plan
./gradlew :grails-data-graphql-core:test :grails-data-graphql:test :grails-data-graphql-core:codeStyle :grails-data-graphql:codeStylepasses🤖 Generated with Claude Code