graphql-java-tools icon indicating copy to clipboard operation
graphql-java-tools copied to clipboard

How to find out the root cause of "Invalid schema provided"?

Open khteh opened this issue 6 years ago • 2 comments

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]

khteh avatar Feb 04 '19 03:02 khteh

Are you using graphql-spring-boot? If not, how are you passing the schema into the the SchemaParser builder?

vojtapol avatar Feb 04 '20 14:02 vojtapol

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!
}

CharlyRipp avatar Dec 10 '20 15:12 CharlyRipp