Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Kotlin value class parameters to data fetchers #1979

Merged
merged 2 commits into from
Aug 5, 2024

Conversation

kilink
Copy link
Member

@kilink kilink commented Aug 5, 2024

Support Kotlin value class parameters as top-level arguments to data fetcher methods.

Fixes #355

Support Kotlin value class parameters as top-level arguments to data fetcher methods.

Fixes #355
@@ -44,6 +47,19 @@ abstract class AbstractInputArgumentResolver(inputObjectMapper: InputObjectMappe
val argumentName = getArgumentName(parameter)
val value = dfe.getArgument<Any?>(argumentName)

val kfunc = parameter.method?.kotlinFunction
if (kfunc != null) {
val parameterIdx = if (kfunc.parameters.first().kind == KParameter.Kind.INSTANCE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this check mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

The first parameter to the KFunction is the instance parameter, e.g. the instance the method is being called on, so we need to adjust the parameter index based on that (essentially start the indexing after this instance parameter).

@kilink kilink merged commit cb279a9 into master Aug 5, 2024
3 checks passed
@kilink kilink deleted the data-fetcher-inline-class-parameter branch August 5, 2024 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Kotlin inline value classes don't work as @InputArgument
2 participants