You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package com.example
import com.expediagroup.graphql.server.ktor.GraphQL
import com.expediagroup.graphql.server.ktor.defaultGraphQLStatusPages
import com.expediagroup.graphql.server.ktor.graphQLPostRoute
import com.expediagroup.graphql.server.ktor.graphiQLRoute
import com.expediagroup.graphql.server.operations.Query
import io.ktor.server.application.*
import io.ktor.server.plugins.statuspages.StatusPages
import io.ktor.server.routing.routing
fun main(args: Array<String>) {
io.ktor.server.netty.EngineMain.main(args)
}
enum class AnimalTypes {
CAT,
DOG
}
interface Animal {
val type: AnimalTypes
fun sound(): String
}
class Cat : Animal {
override val type = AnimalTypes.CAT
override fun sound() = "meow"
fun ignoreEveryone(): String = "ignore everyone"
}
class Dog : Animal {
override val type = AnimalTypes.DOG
override fun sound() = "bark"
fun barkAtEveryone(): String = "bark at everyone"
}
class HelloWorldQuery : Query {
fun getAnimalByType(type: AnimalTypes): Animal = when (type) {
AnimalTypes.CAT -> Cat()
AnimalTypes.DOG -> Dog()
}
}
fun Application.module() {
install(GraphQL) {
schema {
packages = listOf("com.example")
queries = listOf(
HelloWorldQuery()
)
}
}
routing{
graphQLPostRoute()
graphiQLRoute()
}
install(StatusPages) {
defaultGraphQLStatusPages()
}
}
Expected behavior
the query should work fine as it works with ktor 2.x.x and library version 8.2.1
Actual Behaviour
I get an exception on the console
Exception in thread "main" com.expediagroup.graphql.generator.exceptions.ConflictingTypesException: Conflicting class names in schema generation [class com.example.graphql.model.Animal, class com.example.graphql.model.Animal]
at com.expediagroup.graphql.generator.internal.state.TypesCache.get$graphql_kotlin_schema_generator(TypesCache.kt:60)
The same code works fine with ktor version 2.x.x and library version 8.2.1
Attached is minimum reproducible code as a project
Library Version
8.3.0
Describe the bug
I was trying to follow the example given in your documentation here https://opensource.expediagroup.com/graphql-kotlin/docs/schema-generator/writing-schemas/interfaces/
If i try to use an interface it gives me an exception
com.expediagroup.graphql.generator.exceptions.ConflictingTypesException: Conflicting class names in schema generation
To Reproduce
My build.gradle is as follows :
My application.kt is as follows :
Expected behavior
the query should work fine as it works with ktor 2.x.x and library version 8.2.1
Actual Behaviour
I get an exception on the console
The same code works fine with ktor version 2.x.x and library version 8.2.1
Attached is minimum reproducible code as a project
ktor-sample859.zip
The text was updated successfully, but these errors were encountered: