Search in sources :

Example 1 with MissingTypeResolverError

use of graphql.schema.idl.errors.MissingTypeResolverError in project graphql-java by graphql-java.

the class SchemaTypeChecker method checkTypeResolversArePresent.

private void checkTypeResolversArePresent(List<GraphQLError> errors, TypeDefinitionRegistry typeRegistry, RuntimeWiring wiring) {
    Predicate<InterfaceTypeDefinition> noDynamicResolverForInterface = interaceTypeDef -> !wiring.getWiringFactory().providesTypeResolver(new InterfaceWiringEnvironment(typeRegistry, interaceTypeDef));
    Predicate<UnionTypeDefinition> noDynamicResolverForUnion = unionTypeDef -> !wiring.getWiringFactory().providesTypeResolver(new UnionWiringEnvironment(typeRegistry, unionTypeDef));
    Predicate<TypeDefinition> noTypeResolver = typeDefinition -> !wiring.getTypeResolvers().containsKey(typeDefinition.getName());
    Consumer<TypeDefinition> addError = typeDefinition -> errors.add(new MissingTypeResolverError(typeDefinition));
    typeRegistry.types().values().stream().filter(typeDef -> typeDef instanceof InterfaceTypeDefinition).map(InterfaceTypeDefinition.class::cast).filter(noDynamicResolverForInterface).filter(noTypeResolver).forEach(addError);
    typeRegistry.types().values().stream().filter(typeDef -> typeDef instanceof UnionTypeDefinition).map(UnionTypeDefinition.class::cast).filter(noDynamicResolverForUnion).filter(noTypeResolver).forEach(addError);
}
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) MissingTypeResolverError(graphql.schema.idl.errors.MissingTypeResolverError) InterfaceTypeDefinition(graphql.language.InterfaceTypeDefinition) UnionTypeDefinition(graphql.language.UnionTypeDefinition) EnumTypeDefinition(graphql.language.EnumTypeDefinition) OperationTypeDefinition(graphql.language.OperationTypeDefinition) ObjectTypeDefinition(graphql.language.ObjectTypeDefinition) TypeDefinition(graphql.language.TypeDefinition) InterfaceTypeDefinition(graphql.language.InterfaceTypeDefinition) InputObjectTypeDefinition(graphql.language.InputObjectTypeDefinition) UnionTypeDefinition(graphql.language.UnionTypeDefinition)

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