graphql-java-tools
graphql-java-tools copied to clipboard
How to find out the root cause of "Invalid schema provided"?
How to find out the root cause of "Invalid schema provided"? I have many *.graphqls. Some of them just have data type IDL without any query and mutation definition.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'schemaParser' defined in class path resource [com/oembedler/moon/graphql/boot/GraphQLJavaToolsAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.coxautodev.graphql.tools.SchemaParser]: Factory method 'schemaParser' threw exception; nested exception is com.coxautodev.graphql.tools.InvalidSchemaError: Invalid schema provided (org.antlr.v4.runtime.InputMismatchException) at: [@313,1904:1904='[',<11>,120:12]
Are you using graphql-spring-boot? If not, how are you passing the schema into the the SchemaParser builder?
In case this helps anyone else that lands here. Just ran into this and threw me for a loop for a bit - turned out to be that () should be dropped from queries with no parameters.
Example Query
@Service
public class HorribleQuery implements GraphQLQueryResolver {
public String getHorribleExample() {
return "";
}
}
Bad Schema - produces Invalid schema provided (org.antlr.v4.runtime.InputMismatchException)
type Query {
getHorribleExample(): String!
}
Working Schema - removed () from query entry
type Query {
getHorribleExample: String!
}