|
|
@ -5,11 +5,9 @@ |
|
|
// All rights reserved. Licensed under the MIT license.
|
|
|
// All rights reserved. Licensed under the MIT license.
|
|
|
// ==========================================================================
|
|
|
// ==========================================================================
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using GraphQL.Types; |
|
|
using GraphQL.Types; |
|
|
using Squidex.Domain.Apps.Entities.Schemas; |
|
|
using Squidex.Domain.Apps.Entities.Schemas; |
|
|
using Squidex.Infrastructure; |
|
|
|
|
|
|
|
|
|
|
|
namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types |
|
|
namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types |
|
|
{ |
|
|
{ |
|
|
@ -19,6 +17,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types |
|
|
{ |
|
|
{ |
|
|
foreach (var schema in schemas) |
|
|
foreach (var schema in schemas) |
|
|
{ |
|
|
{ |
|
|
|
|
|
var appId = schema.AppId; |
|
|
|
|
|
|
|
|
var schemaId = schema.NamedId(); |
|
|
var schemaId = schema.NamedId(); |
|
|
var schemaType = schema.TypeName(); |
|
|
var schemaType = schema.TypeName(); |
|
|
var schemaName = schema.DisplayName(); |
|
|
var schemaName = schema.DisplayName(); |
|
|
@ -27,74 +27,53 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types |
|
|
|
|
|
|
|
|
var inputType = new ContentDataInputGraphType(schema, schemaName, schemaType, model); |
|
|
var inputType = new ContentDataInputGraphType(schema, schemaName, schemaType, model); |
|
|
|
|
|
|
|
|
AddContentCreate(schemaId, schemaType, schemaName, inputType, contentType); |
|
|
AddField(new FieldType |
|
|
AddContentUpdate(schemaType, schemaName, inputType, contentType); |
|
|
{ |
|
|
AddContentPatch(schemaType, schemaName, inputType, contentType); |
|
|
Name = $"create{schemaType}Content", |
|
|
AddContentChangeStatus(schemaType, schemaName, contentType); |
|
|
Arguments = ContentActions.Create.Arguments(inputType), |
|
|
AddContentDelete(schemaType, schemaName); |
|
|
ResolvedType = contentType, |
|
|
} |
|
|
Resolver = ContentActions.Create.Resolver(appId, schemaId), |
|
|
|
|
|
Description = $"Creates an {schemaName} content." |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
Description = "The app mutations."; |
|
|
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." |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
private void AddContentCreate(NamedId<DomainId> schemaId, string schemaType, string schemaName, ContentDataInputGraphType inputType, IGraphType contentType) |
|
|
AddField(new FieldType |
|
|
{ |
|
|
{ |
|
|
AddField(new FieldType |
|
|
Name = $"patch{schemaType}Content", |
|
|
{ |
|
|
Arguments = ContentActions.UpdateOrPatch.Arguments(inputType), |
|
|
Name = $"create{schemaType}Content", |
|
|
ResolvedType = contentType, |
|
|
Arguments = ContentActions.Create.Arguments(inputType), |
|
|
Resolver = ContentActions.UpdateOrPatch.Patch(appId, schemaId), |
|
|
ResolvedType = contentType, |
|
|
Description = $"Patch an {schemaName} content by id." |
|
|
Resolver = ContentActions.Create.Resolver(schemaId), |
|
|
}); |
|
|
Description = $"Creates an {schemaName} content." |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void AddContentUpdate(string schemaType, string schemaName, ContentDataInputGraphType inputType, IGraphType contentType) |
|
|
AddField(new FieldType |
|
|
{ |
|
|
{ |
|
|
AddField(new FieldType |
|
|
Name = $"publish{schemaType}Content", |
|
|
{ |
|
|
Arguments = ContentActions.ChangeStatus.Arguments, |
|
|
Name = $"update{schemaType}Content", |
|
|
ResolvedType = contentType, |
|
|
Arguments = ContentActions.UpdateOrPatch.Arguments(inputType), |
|
|
Resolver = ContentActions.ChangeStatus.Resolver(appId, schemaId), |
|
|
ResolvedType = contentType, |
|
|
Description = $"Publish a {schemaName} content." |
|
|
Resolver = ContentActions.UpdateOrPatch.Update, |
|
|
}); |
|
|
Description = $"Update an {schemaName} content by id." |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void AddContentPatch(string schemaType, string schemaName, ContentDataInputGraphType inputType, IGraphType contentType) |
|
|
AddField(new FieldType |
|
|
{ |
|
|
{ |
|
|
AddField(new FieldType |
|
|
Name = $"delete{schemaType}Content", |
|
|
{ |
|
|
Arguments = ContentActions.Delete.Arguments, |
|
|
Name = $"patch{schemaType}Content", |
|
|
ResolvedType = EntitySavedGraphType.NonNull, |
|
|
Arguments = ContentActions.UpdateOrPatch.Arguments(inputType), |
|
|
Resolver = ContentActions.Delete.Resolver(appId, schemaId), |
|
|
ResolvedType = contentType, |
|
|
Description = $"Delete an {schemaName} content." |
|
|
Resolver = ContentActions.UpdateOrPatch.Patch, |
|
|
}); |
|
|
Description = $"Patch an {schemaName} content by id." |
|
|
} |
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void AddContentChangeStatus(string schemaType, string schemaName, IGraphType contentType) |
|
|
|
|
|
{ |
|
|
|
|
|
AddField(new FieldType |
|
|
|
|
|
{ |
|
|
|
|
|
Name = $"publish{schemaType}Content", |
|
|
|
|
|
Arguments = ContentActions.ChangeStatus.Arguments, |
|
|
|
|
|
ResolvedType = contentType, |
|
|
|
|
|
Resolver = ContentActions.ChangeStatus.Resolver, |
|
|
|
|
|
Description = $"Publish a {schemaName} content." |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void AddContentDelete(string schemaType, string schemaName) |
|
|
Description = "The app mutations."; |
|
|
{ |
|
|
|
|
|
AddField(new FieldType |
|
|
|
|
|
{ |
|
|
|
|
|
Name = $"delete{schemaType}Content", |
|
|
|
|
|
Arguments = ContentActions.Delete.Arguments, |
|
|
|
|
|
ResolvedType = EntitySavedGraphType.NonNull, |
|
|
|
|
|
Resolver = ContentActions.Delete.Resolver, |
|
|
|
|
|
Description = $"Delete an {schemaName} content." |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|