use of graphql.schema.idl.errors.QueryOperationMissingError in project graphql-java by graphql-java.
the class SchemaTypeChecker method checkSchemaInvariants.
private void checkSchemaInvariants(List<GraphQLError> errors, TypeDefinitionRegistry typeRegistry) {
// schema
if (!typeRegistry.schemaDefinition().isPresent()) {
if (!typeRegistry.getType("Query").isPresent()) {
errors.add(new SchemaMissingError());
}
} else {
SchemaDefinition schemaDefinition = typeRegistry.schemaDefinition().get();
List<OperationTypeDefinition> operationTypeDefinitions = schemaDefinition.getOperationTypeDefinitions();
operationTypeDefinitions.forEach(checkOperationTypesExist(typeRegistry, errors));
operationTypeDefinitions.forEach(checkOperationTypesAreObjects(typeRegistry, errors));
// ensure we have a "query" one
Optional<OperationTypeDefinition> query = operationTypeDefinitions.stream().filter(op -> "query".equals(op.getName())).findFirst();
if (!query.isPresent()) {
errors.add(new QueryOperationMissingError());
}
}
}
Aggregations