Search in sources :

Example 1 with SchemaMissingError

use of graphql.schema.idl.errors.SchemaMissingError 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());
        }
    }
}
Also used : MissingInterfaceTypeError(graphql.schema.idl.errors.MissingInterfaceTypeError) BiFunction(java.util.function.BiFunction) InputValueDefinition(graphql.language.InputValueDefinition) SchemaDefinition(graphql.language.SchemaDefinition) MissingInterfaceFieldError(graphql.schema.idl.errors.MissingInterfaceFieldError) EnumTypeDefinition(graphql.language.EnumTypeDefinition) Type(graphql.language.Type) MissingScalarImplementationError(graphql.schema.idl.errors.MissingScalarImplementationError) EnumValueDefinition(graphql.language.EnumValueDefinition) ObjectTypeExtensionDefinition(graphql.language.ObjectTypeExtensionDefinition) GraphQLError(graphql.GraphQLError) Map(java.util.Map) TypeName(graphql.language.TypeName) QueryOperationMissingError(graphql.schema.idl.errors.QueryOperationMissingError) OperationTypeDefinition(graphql.language.OperationTypeDefinition) ObjectTypeDefinition(graphql.language.ObjectTypeDefinition) InterfaceFieldRedefinitionError(graphql.schema.idl.errors.InterfaceFieldRedefinitionError) Predicate(java.util.function.Predicate) Collection(java.util.Collection) FieldDefinition(graphql.language.FieldDefinition) Set(java.util.Set) TypeDefinition(graphql.language.TypeDefinition) Collectors(java.util.stream.Collectors) BinaryOperator(java.util.function.BinaryOperator) AstPrinter(graphql.language.AstPrinter) MissingTypeError(graphql.schema.idl.errors.MissingTypeError) List(java.util.List) InterfaceTypeDefinition(graphql.language.InterfaceTypeDefinition) Optional(java.util.Optional) NonUniqueArgumentError(graphql.schema.idl.errors.NonUniqueArgumentError) InterfaceFieldArgumentRedefinitionError(graphql.schema.idl.errors.InterfaceFieldArgumentRedefinitionError) SchemaMissingError(graphql.schema.idl.errors.SchemaMissingError) NonUniqueDirectiveError(graphql.schema.idl.errors.NonUniqueDirectiveError) Internal(graphql.Internal) InputObjectTypeDefinition(graphql.language.InputObjectTypeDefinition) SchemaProblem(graphql.schema.idl.errors.SchemaProblem) MissingTypeResolverError(graphql.schema.idl.errors.MissingTypeResolverError) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) UnionTypeDefinition(graphql.language.UnionTypeDefinition) NonUniqueNameError(graphql.schema.idl.errors.NonUniqueNameError) OperationTypesMustBeObjects(graphql.schema.idl.errors.OperationTypesMustBeObjects) InvalidDeprecationDirectiveError(graphql.schema.idl.errors.InvalidDeprecationDirectiveError) MissingInterfaceFieldArgumentsError(graphql.schema.idl.errors.MissingInterfaceFieldArgumentsError) Directive(graphql.language.Directive) Consumer(java.util.function.Consumer) Argument(graphql.language.Argument) StringValue(graphql.language.StringValue) Collections(java.util.Collections) QueryOperationMissingError(graphql.schema.idl.errors.QueryOperationMissingError) SchemaDefinition(graphql.language.SchemaDefinition) SchemaMissingError(graphql.schema.idl.errors.SchemaMissingError) OperationTypeDefinition(graphql.language.OperationTypeDefinition)

Aggregations

GraphQLError (graphql.GraphQLError)1 Internal (graphql.Internal)1 Argument (graphql.language.Argument)1 AstPrinter (graphql.language.AstPrinter)1 Directive (graphql.language.Directive)1 EnumTypeDefinition (graphql.language.EnumTypeDefinition)1 EnumValueDefinition (graphql.language.EnumValueDefinition)1 FieldDefinition (graphql.language.FieldDefinition)1 InputObjectTypeDefinition (graphql.language.InputObjectTypeDefinition)1 InputValueDefinition (graphql.language.InputValueDefinition)1 InterfaceTypeDefinition (graphql.language.InterfaceTypeDefinition)1 ObjectTypeDefinition (graphql.language.ObjectTypeDefinition)1 ObjectTypeExtensionDefinition (graphql.language.ObjectTypeExtensionDefinition)1 OperationTypeDefinition (graphql.language.OperationTypeDefinition)1 SchemaDefinition (graphql.language.SchemaDefinition)1 StringValue (graphql.language.StringValue)1 Type (graphql.language.Type)1 TypeDefinition (graphql.language.TypeDefinition)1 TypeName (graphql.language.TypeName)1 UnionTypeDefinition (graphql.language.UnionTypeDefinition)1