Skip to content

Problems with customTypesMapping and directiveAnnotationsMapping at the same time #1272

@jxnu-liguobin

Description

@jxnu-liguobin

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions