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

resolverArgumentAnnotations not applied in kotlin #1002

Closed
msl-at-fcb opened this issue Sep 12, 2022 · 2 comments
Closed

resolverArgumentAnnotations not applied in kotlin #1002

msl-at-fcb opened this issue Sep 12, 2022 · 2 comments
Assignees
Labels
bug Something isn't working kotlin Pull requests that update Kotlin code
Milestone

Comments

@msl-at-fcb
Copy link
Contributor

Issue Description

The newly introduced resolverArgumentAnnotations configuration (#983) works well in java, but annotations are not applied in kotlin code.

I believe this is just missing code in the kotlin free marker templates. Consider:

https://github.com/kobylynskyi/graphql-java-codegen/blob/master/src/main/resources/templates/java-lang/operations.ftl#L38

and

https://github.com/kobylynskyi/graphql-java-codegen/blob/master/src/main/resources/templates/kotlin-lang/operations.ftl#L41

The kotlin code should look something like (wrapped for clarity):

    fun ${operation.name}(
      <#list operation.parameters as param>
        <#-- include annotations -->
        <#list param.annotations as paramAnnotation>
          @${paramAnnotation}
          <#if param.annotations?has_content> </#if>
        </#list>
        <#-- /include annotations -->
        ${param.name}: ${param.type}
        <#if param_has_next>, </#if>
      </#list>): ${operation.type}

Steps to Reproduce

Generate code using:

{
 "resolverArgumentAnnotations": ["org.springframework.graphql.data.method.annotation.Argument"],
 "language": "JAVA"
}

The relevant @Argument annotation is present.

Replace language with "KOTLIN" and the generated annotation is missing.

Expected Result

Generated code should provide the annotation in both Kotlin and Java.

Actual Result

Generated code provides the annotation in Java but not Kotlin

Your Environment and Setup

  • graphql-java-codegen version: 5.5.0
  • Build tool: Maven
  • Mapping Config:
{
 "resolverArgumentAnnotations": ["org.springframework.graphql.data.method.annotation.Argument"],
 "language": "KOTLIN"
}
@msl-at-fcb msl-at-fcb added the bug Something isn't working label Sep 12, 2022
@jxnu-liguobin jxnu-liguobin added the kotlin Pull requests that update Kotlin code label Sep 12, 2022
@kobylynskyi
Copy link
Owner

@jxnu-liguobin can you please take a look? Thanks

@kobylynskyi
Copy link
Owner

Thanks @msl-at-fcb for working on this. I will include your changes in the upcoming release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working kotlin Pull requests that update Kotlin code
Projects
None yet
Development

No branches or pull requests

3 participants