fix(grails-data-graphql): replace deprecated getContext() in DefaultGraphQLErrorsResponseHandler - #16205
Open
borinquenkid wants to merge 1 commit into
Open
Conversation
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>
1 task
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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:
|
✅ All tests passed ✅🏷️ Commit: 3c7d99e Learn more about TestLens at testlens.app/docs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #16201.
DefaultGraphQLErrorsResponseHandler#getLocale()used the deprecatedDataFetchingEnvironment#getContext().getGraphQlContext()(the modern replacement) can't hold arbitrary objects like this method's supportedLocaleAwareContext, butGraphqlControlleralready sets both.context(context)and.root(context)to the same value specifically for this migration path - sogetLocale()now readsenvironment.rootinstead, covering both the Map-of-locale andLocaleAwareContextcases 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:codeStylepasses🤖 Generated with Claude Code