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

Problems with customTypesMapping and directiveAnnotationsMapping at the same time #1272

Closed
jxnu-liguobin opened this issue Jul 20, 2023 · 3 comments · Fixed by #1298
Closed
Labels
bug Something isn't working

Comments

@jxnu-liguobin
Copy link
Collaborator

jxnu-liguobin commented Jul 20, 2023

schema:

directive @NotNull(message : String, groups: ValidationGroup) on INPUT_FIELD_DEFINITION

input TrustAccountInput
{
  accountId: String! @NotNull(message: "test", groups: CAMS)
}

Plugin config:

<plugin>
                <groupId>io.github.kobylynskyi</groupId>
                <artifactId>graphql-codegen-maven-plugin</artifactId>
                <version>${graphqlcodegen-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <graphqlSchemas>
                        <rootDir>${project.basedir}/src/main/resources/graphql/</rootDir>
                    </graphqlSchemas>
                    <generatedLanguage>KOTLIN</generatedLanguage>
                    <generateEqualsAndHashCode>true</generateEqualsAndHashCode>
                    <outputDir>${project.basedir}/target/generated</outputDir>
                    <addGeneratedAnnotation>false</addGeneratedAnnotation>
                    <generateClient>true</generateClient>
                    <packageName>com.intuit.identity.manage.model</packageName>
                    <modelPackageName>com.intuit.identity.manage.model.graphql</modelPackageName>
                    <apiPackageName>com.intuit.identity.manage.model.querybuilders</apiPackageName>
                    <initializeNullableTypes>true</initializeNullableTypes>
                    <directiveAnnotationsMapping>
                        <ValidAccountId>
                            <f>
                                @com.intuit.identity.manage.account.model.constraints.ValidAccountId
                            </f>
                        </ValidAccountId>
                        <NotBlank>
                            <f>
                                @javax.validation.constraints.NotBlank
                            </f>
                        </NotBlank>
                        <NotNull>
                            <f>
                                @javax.validation.constraints.NotNull(message = {{message}}, groups = {{groups}})
                            </f>
                        </NotNull>
                   
                        <Valid>
                            <f>
                                @javax.validation.Valid
                            </f>
                        </Valid>
                        <Validated>
                            <f>
                                @org.springframework.validation.annotation.Validated
                            </f>
                        </Validated>
                    </directiveAnnotationsMapping>
                    <customTypesMapping>
                        <Date>java.time.LocalDate</Date>
                        <DateTime>java.time.LocalDateTime</DateTime>
                        <CAMS>com.intuit.identity.manage.enum.CamsGroup::class</CAMS>
                    </customTypesMapping>
                    <useObjectMapperForRequestSerialization>
                        Date,DateTime
                    </useObjectMapperForRequestSerialization>
                </configuration>
            </plugin>

Generated class:


import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLRequestSerializer
import java.util.StringJoiner

/**
 * Input for providing trust account in different mutation variations
 */
data class TrustAccountInput(
    @field:javax.validation.constraints.NotNull(message = "test", groups = CAMS)
    var accountId: String
) {...}

Error: Unresolved reference: CAMS

My expectation is that the customTypesMapping replaces theCAMS.

Originally posted by @tejas-sastry in #674 (comment)

@jxnu-liguobin jxnu-liguobin added bug Something isn't working scala Pull requests that update Scala code kotlin Pull requests that update Kotlin code labels Jul 20, 2023
@tejas-sastry
Copy link

@jxnu-liguobin do you plan to pick this up?

@jxnu-liguobin
Copy link
Collaborator Author

@tejas-sastry For me, I may have time this weekend or next to take a look at this issue.
Because this change doesn't seem to involve templates or languages and the implementation is basically the same as Java, So,if someone can do it, that's great, or we can wait a bit.

@jxnu-liguobin
Copy link
Collaborator Author

This seems to be caused by the use of customTypesMapping and directiveAnnotationsMapping at the same time, and it seems that Java has the same problem?

@jxnu-liguobin jxnu-liguobin removed scala Pull requests that update Scala code kotlin Pull requests that update Kotlin code labels Aug 5, 2023
@jxnu-liguobin jxnu-liguobin changed the title Config customTypesMapping not work for kotlin and scala Problems with customTypesMapping and directiveAnnotationsMapping at the same time Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants