File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
graphql-kotlin-toolkit-codegen/src
main/kotlin/com/auritylab/graphql/kotlin/toolkit/codegen/generator
test/kotlin/com/auritylab/graphql/kotlin/toolkit/codegen/generator Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.auritylab.graphql.kotlin.toolkit.codegen.generator
33import com.auritylab.graphql.kotlin.toolkit.codegen.CodegenOptions
44import com.auritylab.graphql.kotlin.toolkit.codegen.mapper.GeneratedMapper
55import com.auritylab.graphql.kotlin.toolkit.codegen.mapper.KotlinTypeMapper
6+ import com.auritylab.graphql.kotlin.toolkit.common.directive.DirectiveFacade
67import com.squareup.kotlinpoet.ClassName
78import com.squareup.kotlinpoet.FileSpec
89import com.squareup.kotlinpoet.FunSpec
@@ -42,10 +43,12 @@ internal class ObjectTypeGenerator(
4243 }
4344
4445 private fun buildProperties (fields : Collection <GraphQLFieldDefinition >): Collection <PropertySpec > {
45- return fields.map {
46- PropertySpec .builder(it.name, getKotlinType(it.type))
47- .initializer(it.name)
48- .build()
49- }
46+ return fields
47+ .filter { ! DirectiveFacade .resolver[it] }
48+ .map {
49+ PropertySpec .builder(it.name, getKotlinType(it.type))
50+ .initializer(it.name)
51+ .build()
52+ }
5053 }
5154}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.auritylab.graphql.kotlin.toolkit.codegen.generator
33import com.auritylab.graphql.kotlin.toolkit.codegen._test.AbstractCompilationTest
44import com.auritylab.graphql.kotlin.toolkit.codegen._test.TestObject
55import graphql.Scalars
6+ import graphql.schema.GraphQLDirective
67import graphql.schema.GraphQLFieldDefinition
78import graphql.schema.GraphQLObjectType
89import org.junit.jupiter.api.Assertions
@@ -36,6 +37,8 @@ internal class ObjectTypeGeneratorTest : AbstractCompilationTest() {
3637
3738 Assertions .assertEquals(" name" , memberProperties[0 ].name)
3839 Assertions .assertEquals(" number" , memberProperties[1 ].name)
40+
41+ // "hasResolver" MUST NOT be present as it's annotated with kResolver.
3942 }
4043}
4144
@@ -50,4 +53,10 @@ val testObjectType = GraphQLObjectType.newObject()
5053 .name(" number" )
5154 .type(Scalars .GraphQLInt )
5255 )
56+ .field(
57+ GraphQLFieldDefinition .newFieldDefinition()
58+ .name(" hasResolver" )
59+ .type(Scalars .GraphQLInt )
60+ .withDirective(GraphQLDirective .newDirective().name(" kResolver" ))
61+ )
5362 .build()
You can’t perform that action at this time.
0 commit comments