Skip to content

refactor(grails-data-graphql): clean up the types package - #16204

Merged
jdaugherty merged 3 commits into
8.1.xfrom
refactor/graphql-types
Sep 30, 2026
Merged

jdaugherty merged 3 commits into
8.1.xfrom
refactor/graphql-types

Conversation

@borinquenkid

@borinquenkid borinquenkid commented Aug 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes a series of IntelliJ-flagged issues in org.grails.gorm.graphql.types.*:

  • DateCoercion: fixed an NPE when no date formats are configured.
  • AbstractObjectTypeBuilder: fixed a control-flow issue where build()'s declared-then-reassigned objectType local confused Groovy's static type checker on objectTypeCache.put(...); fixed an unrelated latent bug where an ArrayList capacity was computed from a not-yet-declared properties variable (which actually resolved to the unrelated GroovyObject#getProperties() bean map); removed an unused parameter from buildInterfaceType; and migrated the deprecated GraphQLInterfaceType.Builder#typeResolver call to registration via GraphQLCodeRegistry.Builder. Added the first direct coverage of the interface-type branch (a root entity with child entities), which no other spec reached.
  • All Coercing implementations in types.scalars.coercing: migrated off the deprecated 1-arg serialize/parseValue/parseLiteral overrides to the context/locale-aware overloads, fixing a ClassCastException-in-waiting in ByteArrayCoercion#parseLiteral, a deprecated Character constructor usage in CharacterArrayCoercion, and an unassigned-variable branch in InstantCoercion#parseLiteral along the way.

Test plan

  • ./gradlew :grails-data-graphql-core:test :grails-data-graphql:test :grails-data-graphql-core:codeStyle :grails-data-graphql:codeStyle passes, including SchemaSpec which exercises these coercions through real GraphQL query execution

🤖 Generated with Claude Code

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

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.2524%. Comparing base (95021df) to head (f2c17f5).
⚠️ Report is 90 commits behind head on 8.1.x.

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                 @@
##                8.1.x     #16204         +/-   ##
===================================================
+ Coverage     32.7869%   59.2524%   +26.4656%     
- Complexity        563      25131      +24568     
===================================================
  Files              84       2215       +2131     
  Lines            4941     108863     +103922     
  Branches          864      19798      +18934     
===================================================
+ Hits             1620      64504      +62884     
- Misses           3061      35424      +32363     
- Partials          260       8935       +8675     

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.

@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 14:27
@jdaugherty
jdaugherty force-pushed the refactor/graphql-types branch from b0f3b14 to 95021df Compare September 30, 2026 14:34
@testlens-app

This comment has been minimized.

borinquenkid and others added 3 commits September 30, 2026 10:51
parseDate() returned a bare null instead of Optional.empty() when
formats was empty, which caused an NPE from parseLiteral()'s
.orElse(null) call on the null return value.

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

- build(entity) declared a blank GraphQLOutputType reassigned across
  if/else branches then passed to objectTypeCache.put(...) - Groovy's
  static type checker narrowed its inferred type to an intersection of
  GraphQLInterfaceType/GraphQLObjectType's common interfaces rather than
  the declared GraphQLOutputType, so put() no longer type-checked.
  Rewrote to return the cached value directly and assign objectType via
  a ternary instead of branch reassignment, the same treatment given to
  DefaultGormDataFetcher.resolveDatastore() earlier in this cleanup.
- Fixed an unrelated latent bug found while touching build(): fields'
  ArrayList capacity was computed from `properties.size()` one line
  before `properties` was declared, which under CompileStatic actually
  resolved to the GroovyObject-inherited `getProperties()` bean-property
  map (an unrelated count), not the domain property list. Moved the
  properties declaration first.
- buildInterfaceType(entity, name, description, fields) never used its
  entity parameter; dropped it (no overrides exist, undocumented).
- GraphQLInterfaceType.Builder#typeResolver(TypeResolver) is deprecated
  since 2018-12-03 in favor of registering the resolver on
  GraphQLCodeRegistry.Builder by interface name, same migration already
  applied to CustomOperation/Schema's dataFetcher registration earlier
  in this cleanup.

Added AbstractObjectTypeBuilderSpec, the first coverage of build()'s
interface-type branch (a root entity with child entities) - the other
object type builder specs construct their builder with a null
GraphQLTypeManager and can't reach build() at all. Backs it with a
minimal Animal/Dog GORM inheritance fixture and verifies the interface
type, the child's implements-interface relationship, and that the
migrated codeRegistry type resolver is actually registered.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
graphql-java deprecated Coercing's 1-arg serialize(Object)/parseValue(Object)/
parseLiteral(Object) since 2022-08-22 in favor of context/locale-aware
overloads: serialize(Object, GraphQLContext, Locale),
parseValue(Object, GraphQLContext, Locale), and
parseLiteral(Value<?>, CoercedVariables, GraphQLContext, Locale). Every
Coercing implementation in this package overrode the old methods.
Migrated all of them - ByteArrayCoercion, CharacterArrayCoercion,
CurrencyCoercion, DateCoercion, SqlDateCoercion, TimeCoercion,
TimeZoneCoercion, TimestampCoercion, URICoercion, URLCoercion,
UUIDCoercion, Jsr310Coercion (the base class LocalDate/LocalDateTime/
LocalTime/OffsetDateTime/OffsetTime/ZonedDateTime all extend, so they
needed no direct changes), and InstantCoercion - to the new signatures.

Fixed three real bugs surfaced while touching these classes:
- ByteArrayCoercion#parseLiteral cast a List<Byte>#toArray() result
  (always an Object[] at runtime) directly to Byte[], which throws
  ClassCastException whenever called. Used toArray(new Byte[0]) instead.
- CharacterArrayCoercion used the deprecated new Character(char)
  constructor in three places; switched to Character.valueOf(char).
- InstantCoercion#parseLiteral declared a blank Object value reassigned
  across an if/else-if with no else branch, so an unrecognized Value
  subtype fell through with value never assigned. Rewrote each branch to
  return directly instead, the same treatment given elsewhere in this
  cleanup, and dropped the now-redundant outer `instanceof Value` check
  since IntValue/StringValue already narrow to Value subtypes.

Updated every coercion spec (18 files) to call the new signatures.
Removed InstantCoercionSpec's "non Value type returns null" test since
that scenario is no longer reachable - the method's static parameter
type is now Value<?>, and the still-present "unrecognized Value type"
test (BooleanValue) covers the equivalent behavior. Verified against
SchemaSpec, which exercises these coercions through real GraphQL query
execution, not just direct unit calls.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jdaugherty
jdaugherty force-pushed the refactor/graphql-types branch from 95021df to f2c17f5 Compare September 30, 2026 14:51
@jdaugherty
jdaugherty merged commit af79fbd into 8.1.x Sep 30, 2026
75 of 78 checks passed
@jdaugherty
jdaugherty deleted the refactor/graphql-types branch September 30, 2026 14:55
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