public override IEnumerable <HealthCheckStatus> GetStatus() { var foundDataTypes = new List <int>(); var contentTypes = _contentTypeService.GetAllContentTypes(); foreach (var contentType in contentTypes) { foundDataTypes.AddRange(contentType.PropertyTypes.Select(p => p.DataTypeDefinitionId)); foundDataTypes.AddRange(contentType.NoGroupPropertyTypes.Select(p => p.DataTypeDefinitionId)); foundDataTypes.AddRange(contentType.CompositionPropertyTypes.Select(p => p.DataTypeDefinitionId)); } var mediaTypes = _contentTypeService.GetAllMediaTypes(); foreach (var mediaType in mediaTypes) { foundDataTypes.AddRange(mediaType.PropertyTypes.Select(p => p.DataTypeDefinitionId)); foundDataTypes.AddRange(mediaType.NoGroupPropertyTypes.Select(p => p.DataTypeDefinitionId)); foundDataTypes.AddRange(mediaType.CompositionPropertyTypes.Select(p => p.DataTypeDefinitionId)); } var unusedDataTypes = _dataTypeService.GetAllDataTypeDefinitions() .Where(d => !d.Name.StartsWith("List View -")) .Where(d => !foundDataTypes.Distinct().Contains(d.Id)) .ToArray(); if (!unusedDataTypes.Any()) { yield return(new HealthCheckStatus("No unused data types found") { ResultType = StatusResultType.Success }); } foreach (var dataType in unusedDataTypes) { yield return(new HealthCheckStatus($"{dataType.Name} does not appear to be used") { ResultType = StatusResultType.Warning }); } }
// TODO: Move registration to another place public UmbracoSchema( IContentTypeService contentTypeService, IMemberTypeService memberTypeService, GraphQLServerOptions options) { if (contentTypeService == null) { throw new ArgumentNullException(nameof(contentTypeService)); } FieldNameConverter = new DefaultFieldNameConverter(); var documentTypes = CreateGraphTypes(contentTypeService.GetAllContentTypes(), PublishedItemType.Content).ToList(); var mediaTypes = CreateGraphTypes(contentTypeService.GetAllMediaTypes(), PublishedItemType.Media).ToList(); //foreach (var documentType in documentTypes.OfType<ComplexGraphType<IPublishedContent>>()) //{ // var allowedChildren = documentType.GetMetadata<string[]>("allowedChildren"); // if (allowedChildren == null || allowedChildren.Length == 0) continue; // var childTypes = // documentTypes.FindAll(x => // allowedChildren.Contains(x.GetMetadata<string>("documentTypeAlias"))); // IGraphType childrenGraphType; // if (childTypes.Count == 1) // { // childrenGraphType = childTypes[0]; // } // else // { // var unionType = new UnionGraphType() // { // Name = $"{documentType.Name}Children", // }; // foreach (var childType in childTypes.OfType<IObjectGraphType>()) // { // unionType.AddPossibleType(childType); // } // childrenGraphType = unionType; // RegisterTypes(unionType); // } // documentType.AddField( // new FieldType // { // Name = "children", // Description = "Children of the content.", // Resolver = new FuncFieldResolver<IPublishedContent, object>(context => context.Source.Children), // ResolvedType = new ListGraphType(childrenGraphType) // } // ); //} RegisterTypes(documentTypes.ToArray()); RegisterTypes(mediaTypes.ToArray()); // RegisterTypes(memberTypeService.GetAll().CreateGraphTypes(PublishedItemType.Member, resolveName).ToArray()); Query = new UmbracoQuery(documentTypes); }
protected override IEnumerable <IContentTypeBase> GetAllContentTypes() { return(_service.GetAllMediaTypes()); }