File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed
main/kotlin/graphql/kickstart/tools/relay
test/kotlin/graphql/kickstart/tools/relay Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 1717 <kotlin .version>1.4.21</kotlin .version>
1818 <kotlin-coroutines .version>1.4.2</kotlin-coroutines .version>
1919 <jackson .version>2.10.3</jackson .version>
20- <graphql-java .version>16.1 </graphql-java .version>
20+ <graphql-java .version>16.2 </graphql-java .version>
2121
2222 <maven .compiler.source>${java.version} </maven .compiler.source>
2323 <maven .compiler.target>${java.version} </maven .compiler.target>
Original file line number Diff line number Diff line change @@ -6,12 +6,18 @@ import graphql.language.*
66class RelayConnectionFactory : TypeDefinitionFactory {
77
88 override fun create (existing : MutableList <Definition <* >>): List <Definition <* >> {
9+ val connectionDirectives = findConnectionDirectives(existing)
10+ if (connectionDirectives.isEmpty()) {
11+ // do not add Relay definitions unless needed
12+ return emptyList()
13+ }
14+
915 val definitions = mutableListOf<Definition <* >>()
1016 val definitionsByName = existing.filterIsInstance<TypeDefinition <* >>()
1117 .associateBy { it.name }
1218 .toMutableMap()
1319
14- findConnectionDirectives(existing)
20+ connectionDirectives
1521 .flatMap { createDefinitions(it) }
1622 .forEach {
1723 if (! definitionsByName.containsKey(it.name)) {
Original file line number Diff line number Diff line change 1+ package graphql.kickstart.tools.relay
2+
3+ import graphql.language.Definition
4+ import org.junit.Assert.assertEquals
5+ import org.junit.Test
6+
7+ class RelayConnectionFactoryTest {
8+
9+ @Test
10+ fun `should not add new definition when no @connection directive` () {
11+ // setup
12+ val factory = RelayConnectionFactory ()
13+ val existing = mutableListOf<Definition <* >>()
14+
15+ val newDefinitions = factory.create(existing)
16+
17+ // expect
18+ assertEquals(newDefinitions.size, 0 )
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments