-
-
Notifications
You must be signed in to change notification settings - Fork 114
Description
Issue Description
I cannot use directiveAnnotationsMapping with directives spotting enum values.
Code generation will fail during issues with the ValueMapper.
Steps to Reproduce
Given
type Actor {
name: String
movies: [Movie] @relationship(type: "ACTED_IN", direction: OUT)
}with a custom directive @relationship, using enum OUT on attribute direction
And the following config
<directiveAnnotationsMapping>
<relationship>
<f>@org.springframework.data.neo4j.core.schema.Relationship(type = {{type}}, direction = {{direction}})</f>
</relationship>
</directiveAnnotationsMapping>Expected Result
I expect the following generated code:
@org.springframework.data.neo4j.core.schema.Relationship(type = "ACTED_IN", direction = OUT)
private java.util.List<Movie> movies;Actual Result
Value Mapper fails:
java.lang.IllegalArgumentException: Unexpected Enum value for list type
at com.kobylynskyi.graphql.codegen.mapper.ValueMapper.mapEnum (ValueMapper.java:132)
at com.kobylynskyi.graphql.codegen.mapper.ValueMapper.map (ValueMapper.java:110)
When using a custom annotation mapping, the GraphQLTypeMapper will always call com.kobylynskyi.graphql.codegen.mapper.ValueMapper#map(com.kobylynskyi.graphql.codegen.model.MappingContext, graphql.language.Value<?>, graphql.language.Type<?>, java.lang.String) with an argument of null for the GraphQL type from
com.kobylynskyi.graphql.codegen.mapper.GraphQLTypeMapper#getAnnotationsForDirective which will eventually trigger the illegal argument exception in com.kobylynskyi.graphql.codegen.mapper.ValueMapper#mapEnum.
Your Environment and Setup
Maven,
<plugin>
<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin</artifactId>
<version>5.1.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- all config options:
https://github.com/kobylynskyi/graphql-java-codegen/blob/master/docs/codegen-options.md
-->
<graphqlSchemas>
<includePattern>schema\.graphqls</includePattern>
</graphqlSchemas>
<outputDir>${project.build.directory}/generated-sources/graphql</outputDir>
<packageName>io.github.kobylynskyi.bikeshop.graphql.model</packageName>
<customTypesMapping>
<DateTime>java.util.Date</DateTime>
<Price.amount>java.math.BigDecimal</Price.amount>
</customTypesMapping>
<customAnnotationsMapping>
<EpochMillis>
<annotation>com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.json.EpochMillisScalarDeserializer.class)</annotation>
</EpochMillis>
</customAnnotationsMapping>
<modelNameSuffix />
<generateBuilder>false</generateBuilder>
<generateImmutableModels>true</generateImmutableModels>
<directiveAnnotationsMapping>
<relationship>
<f>
@org.springframework.data.neo4j.core.schema.Relationship(type = {{type}})
</f>
</relationship>
</directiveAnnotationsMapping>
<customTypesMapping>
<OUT>org.springframework.data.neo4j.core.schema.Relationship.Direction.OUTGOING</OUT>
<IN>org.springframework.data.neo4j.core.schema.Relationship.Direction.OUTGOING</IN>
</customTypesMapping>
</configuration>
</execution>
</executions>
</plugin>See my custom type mappings: It doesn't even look at those as the mapper fails before that.