public AppMutationsGraphType(IGraphModel model, IEnumerable <ISchemaEntity> schemas) { foreach (var schema in schemas) { var schemaId = schema.NamedId(); var schemaType = schema.TypeName(); var schemaName = schema.DisplayName(); var contentType = model.GetContentType(schema.Id); var contentDataType = model.GetContentDataType(schema.Id); var resultType = new ContentDataChangedResultGraphType(schemaType, schemaName, contentDataType); var inputType = new ContentDataGraphInputType(model, schema); AddContentCreate(schemaId, schemaType, schemaName, inputType, contentDataType, contentType); AddContentUpdate(schemaType, schemaName, inputType, resultType); AddContentPatch(schemaType, schemaName, inputType, resultType); AddContentPublish(schemaType, schemaName); AddContentUnpublish(schemaType, schemaName); AddContentArchive(schemaType, schemaName); AddContentRestore(schemaType, schemaName); AddContentDelete(schemaType, schemaName); } Description = "The app mutations."; }
public AppQueriesGraphType(IGraphModel model, int pageSizeContents, int pageSizeAssets, IEnumerable <ISchemaEntity> schemas) { var assetType = model.GetAssetType(); AddAssetFind(assetType); AddAssetsQueries(assetType, pageSizeAssets); foreach (var schema in schemas) { var schemaId = schema.Id; var schemaType = schema.TypeName(); var schemaName = schema.DisplayName(); var contentType = model.GetContentType(schema.Id); AddContentFind( schemaId, schemaType, schemaName, contentType); AddContentQueries( schemaId, schemaType, schemaName, contentType, pageSizeContents); } Description = "The app queries."; }
public AppQueriesGraphType(IGraphModel model, IEnumerable <ISchemaEntity> schemas) { AddField(model.TypeFactory.FindAsset); AddField(model.TypeFactory.QueryAssets); AddField(model.TypeFactory.QueryAssetsWithTotal); foreach (var schema in schemas) { var schemaId = schema.Id; var schemaType = schema.TypeName(); var schemaName = schema.DisplayName(); var contentType = model.GetContentType(schema.Id); AddContentFind( schemaId, schemaType, schemaName, contentType); AddContentQueries( schemaId, schemaType, schemaName, contentType); } Description = "The app queries."; }
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 AppMutationsGraphType(IGraphModel model, IEnumerable <ISchemaEntity> schemas) { foreach (var schema in schemas) { var appId = schema.AppId; var schemaId = schema.NamedId(); var schemaType = schema.TypeName(); var schemaName = schema.DisplayName(); var contentType = model.GetContentType(schema.Id); var inputType = new ContentDataInputGraphType(schema, schemaName, schemaType, model); AddField(new FieldType { Name = $"create{schemaType}Content", Arguments = ContentActions.Create.Arguments(inputType), ResolvedType = contentType, Resolver = ContentActions.Create.Resolver(appId, schemaId), Description = $"Creates an {schemaName} content." }); AddField(new FieldType { Name = $"update{schemaType}Content", Arguments = ContentActions.UpdateOrPatch.Arguments(inputType), ResolvedType = contentType, Resolver = ContentActions.UpdateOrPatch.Update(appId, schemaId), Description = $"Update an {schemaName} content by id." }); AddField(new FieldType { Name = $"patch{schemaType}Content", Arguments = ContentActions.UpdateOrPatch.Arguments(inputType), ResolvedType = contentType, Resolver = ContentActions.UpdateOrPatch.Patch(appId, schemaId), Description = $"Patch an {schemaName} content by id." }); AddField(new FieldType { Name = $"publish{schemaType}Content", Arguments = ContentActions.ChangeStatus.Arguments, ResolvedType = contentType, Resolver = ContentActions.ChangeStatus.Resolver(appId, schemaId), Description = $"Publish a {schemaName} content." }); AddField(new FieldType { Name = $"delete{schemaType}Content", Arguments = ContentActions.Delete.Arguments, ResolvedType = EntitySavedGraphType.NonNull, Resolver = ContentActions.Delete.Resolver(appId, schemaId), Description = $"Delete an {schemaName} content." }); } Description = "The app mutations."; }