hotchoc schema builder error
Ran into this error when trying to get my graphql running
"The schema builder was unable to identify the query type of the schema. Either specify which type is the query type or set the schema builder to non-strict validation mode."
To resolve this we either had to downgrade schema checking, for example
builder.Services
.AddGraphQLServer()
.ConfigureSchema(sb => sb.ModifyOptions(opts => opts.StrictValidation = false))
.AddSubscriptionType<Subscription>()
.AddMutationType<Mutation>()
.AddInMemorySubscriptions();
Or adds a dummy AddQueryType, as shown below.
builder.Services
.AddGraphQLServer()
//.ConfigureSchema(sb => sb.ModifyOptions(opts => opts.StrictValidation = false))
.AddSubscriptionType<Subscription>()
.AddMutationType<Mutation>()
.AddQueryType<Query>()
.AddInMemorySubscriptions();
And the Query code looks something like this.
public class Query
{
public string HelloWorld()
{
return "Hello, from GraphQL!";
}
}
Comments