Repository navigation
Resolve type variables in resolver parameter types - #882
Merged
Merged
Conversation
|
2 tasks done
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.



Fixes #880
Checklist
Description
A resolver method inherited from a generic class, with the class's type variable as its parameter, built fine but failed on every query:
The scanner resolves
ItoGreetingInputinTypeClassMatcher, so the build passes. The data fetcher tookMethodFieldResolver#getMethodParameterTypeas is, which is the rawIfromMethod#getGenericParameterTypes, andshouldValueBeConvertedcast it toClassinJavaType.unwrap().ArgumentConvertergot the rawItoo, which Jackson reads asObject, so I think fixing only the cast would have handed the method aMap.So
getMethodParameterTypenow resolves the type variables against the resolver class withGenericTypeResolver#resolveTypeVariables(no longer private). Every caller gets the resolved type, so the scanner and the data fetcher start from the same one. I also dropped the?.apply { typeResolver.getRawClass(this) }increateDataFetcher, since its result was thrown away.I tried
GenericTypeResolver#resolvefirst, but it also unwraps generic wrappers and boxes primitives. That brokeResolverMethodsTest.testOmittedBooleanArgument: an omitted argument for abooleanparameter becamenullinstead offalse, and the call failed.resolveTypeVariablesonly replaces the type variables, andTypeClassMatcherstill callsresolveon top of it for the scan.The unmapped input field check from #857 reads the same type, so it now checks inputs typed by a type variable too. Before, they weren't checked. So the generic case in
UnmappedInputFieldsTestmoves from the "can't be checked" test to the one that reports, and theQuery.genericexclusion from #879 is gone.Added a case with the issue's schema to
GenericResolverTest. It failed with the cast error before the fix.mvn clean verifypasses on JDK 25, on JDK 25 against graphql-java 25.1, and on JDK 11. Also checked through the public API:{ generic(input: { name: "a" }) }failed on master on graphql-java 26.1 and 25.1, and returnsgeneric got GreetingInput(name=a)on both with this change.