Skip to content

chore(grails-data-graphql): root-level cleanup (GraphQLEntityHelper, GraphQLServiceManager, Schema) - #16207

Merged
jdaugherty merged 4 commits into
8.1.xfrom
chore/graphql-root-cleanup
Sep 30, 2026
Merged

jdaugherty merged 4 commits into
8.1.xfrom
chore/graphql-root-cleanup

Conversation

@borinquenkid

@borinquenkid borinquenkid commented Aug 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Root-package cleanup in grails-data-graphql, rebased onto 8.1.x now that #16201 is merged:

  • GraphQLEntityHelper#getMapping: consolidated a four-branch reassignment of mapping into single-return helper methods (findGraphqlProperty, toGraphQLMapping, buildMapping), fixing a false "assignment is not used" flag. The Closure branch now calls the static GraphQLMapping.build(Closure) directly instead of through a throwaway instance, and the post-conversion check is a plain null check.
  • GraphQLServiceManager#getService: removed a redundant public modifier (Groovy methods are public by default).
  • Schema#generate(): made the implicit null return explicit when no entity contributes any query fields, satisfying "not all execution paths return a value" with no behavior change (already covered by DisableAllOpSpec).

Added direct unit coverage for getMapping (previously only exercised indirectly via getDescription): no static graphql property, Boolean true, Closure, LazyGraphQLMapping, prebuilt GraphQLMapping, an unsupported property type, cache identity across repeated calls, and verifyMapping's existing-property check, which had no test anywhere.

Test plan

  • ./gradlew :grails-data-graphql-core:test :grails-data-graphql:test :grails-data-graphql-core:codeStyle :grails-data-graphql:codeStyle passes

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings August 23, 2026 16:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.2574%. Comparing base (95021df) to head (1c85119).
⚠️ Report is 90 commits behind head on 8.1.x.

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                 @@
##                8.1.x     #16207         +/-   ##
===================================================
+ Coverage     32.7869%   59.2574%   +26.4705%     
- Complexity        563      25148      +24585     
===================================================
  Files              84       2215       +2131     
  Lines            4941     108864     +103923     
  Branches          864      19797      +18933     
===================================================
+ Hits             1620      64510      +62890     
- Misses           3061      35424      +32363     
- Partials          260       8930       +8670     

see 2131 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@testlens-app

This comment has been minimized.

@jdaugherty
jdaugherty force-pushed the test/grails-data-graphql-coverage branch from 36b7716 to df7efef Compare September 23, 2026 21:15
Base automatically changed from test/grails-data-graphql-coverage to 8.0.x September 23, 2026 21:16
@jdaugherty
jdaugherty changed the base branch from 8.0.x to 8.1.x September 30, 2026 15:06
borinquenkid and others added 4 commits September 30, 2026 11:07
mapping was declared null then conditionally reassigned across four
if/else-if branches before being read - the same shape flagged
elsewhere in this cleanup as a false "assignment is not used" warning
once IntelliJ's flow analysis loses track of a variable reassigned
across many branches. Extracted the reflection lookup
(findGraphqlProperty), the graphql-value-to-GraphQLMapping conversion
(toGraphQLMapping, with each branch returning directly), and the
overall build/verify sequence (buildMapping) into their own methods,
so getMapping itself is now a single containsKey-check plus a
single build+cache assignment.

Added direct unit coverage for getMapping via a Stub(PersistentEntity)
(no static graphql property, a Boolean true, an unsupported property
type that should throw IllegalMappingException, and cache identity
across repeated calls) - previously it was only exercised indirectly
through getDescription and other specs' Closure-based mappings.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Groovy methods are public by default; the explicit modifier was
redundant.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
When no entity contributes any query fields, the method fell off the
end without a return statement instead of explicitly returning null.
Behavior is unchanged (Groovy allows the implicit null under
CompileStatic), but the fall-through was ambiguous to both the reader
and the compiler's control-flow analysis. Already covered by
DisableAllOpSpec, which asserts generate() returns null when every
entity's operations are disabled.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ng branches

The Closure branch of toGraphQLMapping allocated a throwaway
GraphQLMapping only to call the static build(Closure) through it; call
it on the class directly. buildMapping's instanceof check on a variable
already typed as GraphQLMapping reduces to a null check.

Add direct getMapping coverage for the Closure, LazyGraphQLMapping and
prebuilt GraphQLMapping branches, and for verifyMapping's property
check, which had no test anywhere: a mapped property that exists on the
entity is accepted, and one that does not raises IllegalMappingException
naming the property and the entity class.
@jdaugherty
jdaugherty force-pushed the chore/graphql-root-cleanup branch from cc285e7 to 1c85119 Compare September 30, 2026 15:13
@jdaugherty
jdaugherty merged commit 712ac5d into 8.1.x Sep 30, 2026
76 of 80 checks passed
@jdaugherty
jdaugherty deleted the chore/graphql-root-cleanup branch September 30, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants