|
|
|
@ -7,7 +7,6 @@ |
|
|
|
|
|
|
|
using GraphQL.Types; |
|
|
|
using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents; |
|
|
|
using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Primitives; |
|
|
|
|
|
|
|
namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types; |
|
|
|
|
|
|
|
@ -17,15 +16,29 @@ internal sealed class ApplicationMutations : ObjectGraphType |
|
|
|
{ |
|
|
|
foreach (var schemaInfo in schemas.Where(x => x.Fields.Count > 0)) |
|
|
|
{ |
|
|
|
var contentType = new NonNullGraphType(builder.GetContentType(schemaInfo)); |
|
|
|
|
|
|
|
var inputType = new DataInputGraphType(builder, schemaInfo); |
|
|
|
|
|
|
|
// We cannot check before if all fields can be resolved. This might not be the case, e.g. if a reference is empty.
|
|
|
|
if (inputType.Fields.Count == 0) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
var contentType = builder.GetContentType(schemaInfo); |
|
|
|
|
|
|
|
// We cannot check before if all fields can be resolved. This might not be the case, e.g. if a reference is empty.
|
|
|
|
if (contentType == null || contentType.Fields.Count == 0) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
var nonNullContentType = new NonNullGraphType(contentType); |
|
|
|
|
|
|
|
AddField(new FieldType |
|
|
|
{ |
|
|
|
Name = $"create{schemaInfo.TypeName}Content", |
|
|
|
Arguments = ContentActions.Create.Arguments(inputType), |
|
|
|
ResolvedType = contentType, |
|
|
|
ResolvedType = nonNullContentType, |
|
|
|
Resolver = ContentActions.Create.Resolver, |
|
|
|
Description = $"Creates an {schemaInfo.DisplayName} content." |
|
|
|
}).WithSchemaNamedId(schemaInfo); |
|
|
|
@ -34,7 +47,7 @@ internal sealed class ApplicationMutations : ObjectGraphType |
|
|
|
{ |
|
|
|
Name = $"update{schemaInfo.TypeName}Content", |
|
|
|
Arguments = ContentActions.Update.Arguments(inputType), |
|
|
|
ResolvedType = contentType, |
|
|
|
ResolvedType = nonNullContentType, |
|
|
|
Resolver = ContentActions.Update.Resolver, |
|
|
|
Description = $"Update an {schemaInfo.DisplayName} content by id." |
|
|
|
}).WithSchemaNamedId(schemaInfo); |
|
|
|
@ -43,7 +56,7 @@ internal sealed class ApplicationMutations : ObjectGraphType |
|
|
|
{ |
|
|
|
Name = $"upsert{schemaInfo.TypeName}Content", |
|
|
|
Arguments = ContentActions.Upsert.Arguments(inputType), |
|
|
|
ResolvedType = contentType, |
|
|
|
ResolvedType = nonNullContentType, |
|
|
|
Resolver = ContentActions.Upsert.Resolver, |
|
|
|
Description = $"Upsert an {schemaInfo.DisplayName} content by id." |
|
|
|
}).WithSchemaNamedId(schemaInfo); |
|
|
|
@ -52,38 +65,10 @@ internal sealed class ApplicationMutations : ObjectGraphType |
|
|
|
{ |
|
|
|
Name = $"patch{schemaInfo.TypeName}Content", |
|
|
|
Arguments = ContentActions.Patch.Arguments(inputType), |
|
|
|
ResolvedType = contentType, |
|
|
|
ResolvedType = nonNullContentType, |
|
|
|
Resolver = ContentActions.Patch.Resolver, |
|
|
|
Description = $"Patch an {schemaInfo.DisplayName} content by id." |
|
|
|
}).WithSchemaNamedId(schemaInfo); |
|
|
|
|
|
|
|
AddField(new FieldType |
|
|
|
{ |
|
|
|
Name = $"change{schemaInfo.TypeName}Content", |
|
|
|
Arguments = ContentActions.ChangeStatus.Arguments, |
|
|
|
ResolvedType = contentType, |
|
|
|
Resolver = ContentActions.ChangeStatus.Resolver, |
|
|
|
Description = $"Change a {schemaInfo.DisplayName} content." |
|
|
|
}).WithSchemaNamedId(schemaInfo); |
|
|
|
|
|
|
|
AddField(new FieldType |
|
|
|
{ |
|
|
|
Name = $"delete{schemaInfo.TypeName}Content", |
|
|
|
Arguments = ContentActions.Delete.Arguments, |
|
|
|
ResolvedType = EntitySavedGraphType.NonNull, |
|
|
|
Resolver = ContentActions.Delete.Resolver, |
|
|
|
Description = $"Delete an {schemaInfo.DisplayName} content." |
|
|
|
}).WithSchemaNamedId(schemaInfo); |
|
|
|
|
|
|
|
AddField(new FieldType |
|
|
|
{ |
|
|
|
Name = $"publish{schemaInfo.TypeName}Content", |
|
|
|
Arguments = ContentActions.ChangeStatus.Arguments, |
|
|
|
ResolvedType = contentType, |
|
|
|
Resolver = ContentActions.ChangeStatus.Resolver, |
|
|
|
Description = $"Publish a {schemaInfo.DisplayName} content.", |
|
|
|
DeprecationReason = $"Use 'change{schemaInfo.TypeName}Content' instead" |
|
|
|
}).WithSchemaNamedId(schemaInfo); |
|
|
|
} |
|
|
|
|
|
|
|
Description = "The app mutations."; |
|
|
|
|