Skip to content

fix(grails-data-graphql): replace deprecated getContext() in DefaultGraphQLErrorsResponseHandler - #16205

Open
borinquenkid wants to merge 1 commit into
test/grails-data-graphql-coveragefrom
fix/graphql-errors-response
Open

fix(grails-data-graphql): replace deprecated getContext() in DefaultGraphQLErrorsResponseHandler#16205
borinquenkid wants to merge 1 commit into
test/grails-data-graphql-coveragefrom
fix/graphql-errors-response

Conversation

@borinquenkid

Copy link
Copy Markdown
Member

Summary

Stacked on #16201. DefaultGraphQLErrorsResponseHandler#getLocale() used the deprecated DataFetchingEnvironment#getContext(). getGraphQlContext() (the modern replacement) can't hold arbitrary objects like this method's supported LocaleAwareContext, but GraphqlController already sets both .context(context) and .root(context) to the same value specifically for this migration path - so getLocale() now reads environment.root instead, covering both the Map-of-locale and LocaleAwareContext cases with no behavior change. Added the previously-missing root-Map and no-locale-entry test branches.

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

getContext() has been deprecated in graphql-java since 2021-07-05 in
favor of getGraphQlContext(), but the latter only accepts Map entries
and can't carry an arbitrary object such as a custom
GraphQLContextBuilder result implementing LocaleAwareContext.
GraphqlController already sets both .context(context) and
.root(context) to the same value specifically so callers can move off
the legacy context; switch getLocale() to read environment.root
instead, which covers both the Map-of-locale and LocaleAwareContext
cases without changing behavior.

Updated the existing LocaleAwareContext spec to stub root instead of
context, and added coverage for the root-Map-with-locale and
no-locale-entry-falls-back-to-default branches, which weren't
separately tested before.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
⚠️ Please upload report for BASE (test/grails-data-graphql-coverage@36b7716). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@                          Coverage Diff                           @@
##             test/grails-data-graphql-coverage     #16205   +/-   ##
======================================================================
  Coverage                                     ?   53.4230%           
  Complexity                                   ?      19461           
======================================================================
  Files                                        ?       2081           
  Lines                                        ?      98993           
  Branches                                     ?      17361           
======================================================================
  Hits                                         ?      52885           
  Misses                                       ?      38558           
  Partials                                     ?       7550           
🚀 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

testlens-app Bot commented Aug 23, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 3c7d99e
▶️ Tests: 47656 executed
⚪️ Checks: 70/70 completed


Learn more about TestLens at testlens.app/docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants