Using com.graphql-java-kickstart:graphql-spring-boot-starter:14.1.0
I was refactoring some code to switch Strings
for enums
and I got the following error.
Caused by: graphql.kickstart.tools.SchemaError: Type 'Integration' is declared as an enum in the GraphQL schema but is not a Java enum!
I double checked, and Integration
was in the GraphQL correctly, and was also a proper Java enum.
GraphQL:
enum Integration {
STRIPE
}
input IntegrationCriteria {
integration: Integration
identifier: String
}
Java enum:
public enum Integration {
STRIPE;
}
Putting a breakpoint in the GraphQL code, the enum code resolves the type via dictionary
.
private fun createEnumObject(definition: EnumTypeDefinition): GraphQLEnumType {
val name = definition.name
val type = dictionary[definition]
?: throw SchemaError("Expected enum with name '$name' but found none!")
if (!type.unwrap().isEnum) throw SchemaError("Type '$name' is declared as an enum in the GraphQL schema but is not a Java enum!")
...
It turns out dictionary
is derived from the types used in the referenced classes.
It turns out that in my refactoring I’d changed the wrong String. The error didn’t actually point to this as the error though, it said
public class IntegrationCriteria {
// WRONG
private Integration identifier;
private String integration;
}