Skip to content

Commit

Permalink
Add generic interface to federation tests
Browse files Browse the repository at this point in the history
Adding generic sealed interface to tests and removing restrictive checks
  • Loading branch information
oas004 committed Nov 7, 2024
1 parent 3e89cc6 commit d7f18f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ private class TypeDefinitionContext(
}
usedNames.add(name)

if (declaration.typeParameters.isNotEmpty()) {
logger.error("Generic classes are not supported")
typeDefinitions.put(qualifiedName, null)
continue
}

if (unsupportedTypes.contains(qualifiedName)) {
logger.error(
"'$qualifiedName' is not a supported built-in type. Either use one of the built-in types (Boolean, String, Int, Double) or use a custom scalar.",
Expand Down Expand Up @@ -353,6 +347,7 @@ private class TypeDefinitionContext(
GQLEnumValue(null, simpleName.asString())
}
}

else -> {
logger.error("Cannot convert $this to a GQLValue", argument)
GQLNullValue(null) // not correct but compilation should fail anyway
Expand Down Expand Up @@ -477,10 +472,7 @@ private class TypeDefinitionContext(
private fun KSClassDeclaration.interfaces(): List<String> {
return getAllSuperTypes().mapNotNull {
val declaration = it.declaration
if (it.arguments.isNotEmpty()) {
logger.error("Generic interfaces are not supported", this)
null
} else if (declaration is KSClassDeclaration) {
if (declaration is KSClassDeclaration) {
if (declaration.asClassName().asString() == "kotlin.Any") {
null
} else if (declaration.containingFile == null) {
Expand Down
4 changes: 3 additions & 1 deletion tests/federation/src/main/kotlin/graphql.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import com.apollographql.execution.annotation.GraphQLQuery
import com.apollographql.execution.subgraph.GraphQLKey

sealed interface SomeGenericInterface<T>

@GraphQLQuery
class Query {
class Query: SomeGenericInterface<String>{
fun products(): List<Product> {
return products
}
Expand Down

0 comments on commit d7f18f6

Please sign in to comment.