public void Initialize(IGraphModel model) { AddField(new FieldType { Name = "url", ResolvedType = AllTypes.NonNullString, Resolver = model.ResolveContentUrl(schema), Description = $"The url to the the {schemaName} content." }); var contentDataType = new ContentDataGraphType(schema, schemaName, schemaType, model); if (contentDataType.Fields.Any()) { AddField(new FieldType { Name = "data", ResolvedType = new NonNullGraphType(contentDataType), Resolver = Resolve(x => x.Data), Description = $"The data of the {schemaName} content." }); AddField(new FieldType { Name = "dataDraft", ResolvedType = contentDataType, Resolver = Resolve(x => x.DataDraft), Description = $"The draft data of the {schemaName} content." }); } }
public void Initialize(IGraphModel model, ISchemaEntity schema, IEnumerable <ISchemaEntity> all, int pageSize) { var schemaType = schema.TypeName(); var schemaName = schema.DisplayName(); AddField(new FieldType { Name = "url", ResolvedType = AllTypes.NonNullString, Resolver = ContentResolvers.Url, Description = $"The url to the the {schemaName} content." }); var contentDataType = new ContentDataGraphType(schema, schemaName, schemaType, model); if (contentDataType.Fields.Any()) { AddField(new FieldType { Name = "data", ResolvedType = new NonNullGraphType(contentDataType), Resolver = ContentResolvers.Data, Description = $"The data of the {schemaName} content." }); } var contentDataTypeFlat = new ContentDataFlatGraphType(schema, schemaName, schemaType, model); if (contentDataTypeFlat.Fields.Any()) { AddField(new FieldType { Name = "flatData", ResolvedType = new NonNullGraphType(contentDataTypeFlat), Resolver = ContentResolvers.FlatData, Description = $"The flat data of the {schemaName} content." }); } foreach (var other in all.Where(x => References(x, schema))) { var referencingId = other.Id; var referencingType = other.TypeName(); var referencingName = other.DisplayName(); var contentType = model.GetContentType(referencingId); AddReferencingQueries(referencingId, referencingType, referencingName, contentType, pageSize); } }
public void Initialize(IGraphModel model) { AddField(new FieldType { Name = "url", ResolvedType = AllTypes.NonNullString, Resolver = ContentResolvers.Url, Description = $"The url to the the {schemaName} content." }); var contentDataType = new ContentDataGraphType(schema, schemaName, schemaType, model); if (contentDataType.Fields.Any()) { AddField(new FieldType { Name = "data", ResolvedType = new NonNullGraphType(contentDataType), Resolver = ContentResolvers.Data, Description = $"The data of the {schemaName} content." }); } var contentDataTypeFlat = new ContentDataFlatGraphType(schema, schemaName, schemaType, model); if (contentDataTypeFlat.Fields.Any()) { AddField(new FieldType { Name = "flatData", ResolvedType = new NonNullGraphType(contentDataTypeFlat), Resolver = ContentResolvers.FlatData, Description = $"The flat data of the {schemaName} content." }); } }
public void Initialize() { var schemaName = schema.SchemaDef.Properties.Label.WithFallback(schema.Name); AddField(new FieldType { Name = "id", Resolver = Resolver(x => x.Id.ToString()), ResolvedType = new NonNullGraphType(new StringGraphType()), Description = $"The id of the {schemaName} content." }); AddField(new FieldType { Name = "version", Resolver = Resolver(x => x.Version), ResolvedType = new NonNullGraphType(new IntGraphType()), Description = $"The version of the {schemaName} content." }); AddField(new FieldType { Name = "created", Resolver = Resolver(x => x.Created.ToDateTimeUtc()), ResolvedType = new NonNullGraphType(new DateGraphType()), Description = $"The date and time when the {schemaName} content has been created." }); AddField(new FieldType { Name = "createdBy", Resolver = Resolver(x => x.CreatedBy.ToString()), ResolvedType = new NonNullGraphType(new StringGraphType()), Description = $"The user that has created the {schemaName} content." }); AddField(new FieldType { Name = "lastModified", Resolver = Resolver(x => x.LastModified.ToDateTimeUtc()), ResolvedType = new NonNullGraphType(new DateGraphType()), Description = $"The date and time when the {schemaName} content has been modified last." }); AddField(new FieldType { Name = "lastModifiedBy", Resolver = Resolver(x => x.LastModifiedBy.ToString()), ResolvedType = new NonNullGraphType(new StringGraphType()), Description = $"The user that has updated the {schemaName} content last." }); AddField(new FieldType { Name = "url", Resolver = context.ResolveContentUrl(schema), ResolvedType = new NonNullGraphType(new StringGraphType()), Description = $"The url to the the {schemaName} content." }); var dataType = new ContentDataGraphType(schema.SchemaDef, context); if (dataType.Fields.Any()) { AddField(new FieldType { Name = "data", Resolver = Resolver(x => x.Data), ResolvedType = new NonNullGraphType(dataType), Description = $"The data of the {schemaName} content." }); } Description = $"The structure of a {schemaName} content type."; }