Skip to content

Unable to generate Kotlin data classes with custom annotations applied on field(by default, it's applied on getter). #1263

@rachana-sudhindradani

Description

@rachana-sudhindradani

I am using below configuration

<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>
                    <customTypesMapping>
                        <Date>java.time.LocalDate</Date>
                        <DateTime>java.time.LocalDateTime</DateTime>
                    </customTypesMapping>
                    <useObjectMapperForRequestSerialization>
                        Date,DateTime
                    </useObjectMapperForRequestSerialization>
                    <customAnnotationsMapping>
                        <TrustedAccountInput.accountId>
                            <annotation>com.intuit.identity.manage.account.model.constraints.ValidAccountId</annotation>
                        </TrustedAccountInput.accountId>
                    </customAnnotationsMapping>
                </configuration>
            </plugin>

And the model classes generated is like so

data class TrustedAccountInput(
    @get:com.intuit.identity.manage.account.model.constraints.ValidAccountId
    var accountId: String,
    var mirrorProfile: ProfileInput? = null,
    var trustGrant: TrustGrantInput,
    var primaryProfile: PrimaryProfileInput? = null,
    var mirrorPrimaryProfile: Boolean? = null
) {/*some impl here*/}

Can you please let me know what config change has to be added to apply the custom annotation on field instead of getter.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingkotlinPull requests that update Kotlin code

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions