From 5d9d74a100f7bdbad42a2c53f91901dcaa1cb3c4 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Fri, 27 May 2022 21:49:54 +0200 Subject: [PATCH] Fix graphql memory leak. (#883) --- .../GraphQL/Types/Assets/AssetActions.cs | 12 ++--- .../GraphQL/Types/Assets/AssetGraphType.cs | 50 ++++++++--------- .../Types/Assets/AssetsResultGraphType.cs | 2 +- .../Contents/GraphQL/Types/Builder.cs | 8 ++- .../Types/Contents/ComponentGraphType.cs | 4 +- .../GraphQL/Types/Contents/ContentActions.cs | 54 +++++++++---------- .../GraphQL/Types/Contents/ContentFields.cs | 28 +++++----- .../Types/Contents/ContentGraphType.cs | 2 +- .../Types/Contents/ContentResultGraphType.cs | 2 +- .../Types/Contents/DataFlatGraphType.cs | 2 +- .../GraphQL/Types/Contents/DataGraphType.cs | 2 +- .../Types/Contents/FieldInputVisitor.cs | 22 ++++---- .../GraphQL/Types/Contents/FieldVisitor.cs | 14 ++--- .../GraphQL/Types/Contents/NestedGraphType.cs | 2 +- .../Types/Primitives/EntitySavedGraphType.cs | 2 +- .../GraphQL/Types/{AllTypes.cs => Scalars.cs} | 2 +- .../Contents/GraphQL/Types/SharedTypes.cs | 4 -- .../Contents/GraphQL/Types/UserGraphType.cs | 6 +-- backend/src/Squidex/Squidex.csproj | 5 +- 19 files changed, 113 insertions(+), 110 deletions(-) rename backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/{AllTypes.cs => Scalars.cs} (98%) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs index c6377677b..9423c149e 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs @@ -20,7 +20,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets { public static readonly QueryArguments Arguments = new QueryArguments { - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "path", Description = FieldDescriptions.JsonPath, @@ -46,7 +46,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets { public static readonly QueryArguments Arguments = new QueryArguments { - new QueryArgument(AllTypes.NonNullString) + new QueryArgument(Scalars.NonNullString) { Name = "id", Description = "The id of the asset (usually GUID).", @@ -67,25 +67,25 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets { public static readonly QueryArguments Arguments = new QueryArguments { - new QueryArgument(AllTypes.Int) + new QueryArgument(Scalars.Int) { Name = "top", Description = "Optional number of assets to take.", DefaultValue = null }, - new QueryArgument(AllTypes.Int) + new QueryArgument(Scalars.Int) { Name = "skip", Description = "Optional number of assets to skip.", DefaultValue = 0 }, - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "filter", Description = "Optional OData filter.", DefaultValue = null }, - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "orderby", Description = "Optional OData order definition.", diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetGraphType.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetGraphType.cs index c6a185fe3..441a86d92 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetGraphType.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetGraphType.cs @@ -26,7 +26,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "id", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = EntityResolvers.Id, Description = FieldDescriptions.EntityId }); @@ -34,7 +34,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "version", - ResolvedType = AllTypes.NonNullInt, + ResolvedType = Scalars.NonNullInt, Resolver = EntityResolvers.Version, Description = FieldDescriptions.EntityVersion }); @@ -42,7 +42,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "created", - ResolvedType = AllTypes.NonNullDateTime, + ResolvedType = Scalars.NonNullDateTime, Resolver = EntityResolvers.Created, Description = FieldDescriptions.EntityCreated }); @@ -50,7 +50,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "createdBy", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = EntityResolvers.CreatedBy, Description = FieldDescriptions.EntityCreatedBy }); @@ -66,7 +66,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "lastModified", - ResolvedType = AllTypes.NonNullDateTime, + ResolvedType = Scalars.NonNullDateTime, Resolver = EntityResolvers.LastModified, Description = FieldDescriptions.EntityLastModified }); @@ -74,7 +74,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "lastModifiedBy", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = EntityResolvers.LastModifiedBy, Description = FieldDescriptions.EntityLastModifiedBy }); @@ -90,7 +90,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "mimeType", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = Resolve(x => x.MimeType), Description = FieldDescriptions.AssetMimeType }); @@ -98,7 +98,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "url", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = Url, Description = FieldDescriptions.AssetUrl }); @@ -106,7 +106,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "thumbnailUrl", - ResolvedType = AllTypes.String, + ResolvedType = Scalars.String, Resolver = ThumbnailUrl, Description = FieldDescriptions.AssetThumbnailUrl }); @@ -114,7 +114,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "fileName", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = Resolve(x => x.FileName), Description = FieldDescriptions.AssetFileName }); @@ -122,7 +122,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "fileHash", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = Resolve(x => x.FileHash), Description = FieldDescriptions.AssetFileHash }); @@ -130,7 +130,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "fileType", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = Resolve(x => x.FileName.FileType()), Description = FieldDescriptions.AssetFileType }); @@ -138,7 +138,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "fileSize", - ResolvedType = AllTypes.NonNullInt, + ResolvedType = Scalars.NonNullInt, Resolver = Resolve(x => x.FileSize), Description = FieldDescriptions.AssetFileSize }); @@ -146,7 +146,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "fileVersion", - ResolvedType = AllTypes.NonNullInt, + ResolvedType = Scalars.NonNullInt, Resolver = Resolve(x => x.FileVersion), Description = FieldDescriptions.AssetFileVersion }); @@ -154,7 +154,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "slug", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = Resolve(x => x.Slug), Description = FieldDescriptions.AssetSlug }); @@ -162,7 +162,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "isProtected", - ResolvedType = AllTypes.NonNullBoolean, + ResolvedType = Scalars.NonNullBoolean, Resolver = Resolve(x => x.IsProtected), Description = FieldDescriptions.AssetIsProtected }); @@ -170,7 +170,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "isImage", - ResolvedType = AllTypes.NonNullBoolean, + ResolvedType = Scalars.NonNullBoolean, Resolver = Resolve(x => x.Type == AssetType.Image), Description = FieldDescriptions.AssetIsImage, DeprecationReason = "Use 'type' field instead." @@ -179,7 +179,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "pixelWidth", - ResolvedType = AllTypes.Int, + ResolvedType = Scalars.Int, Resolver = Resolve(x => x.Metadata.GetPixelWidth()), Description = FieldDescriptions.AssetPixelWidth, DeprecationReason = "Use 'metadata' field instead." @@ -188,7 +188,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "pixelHeight", - ResolvedType = AllTypes.Int, + ResolvedType = Scalars.Int, Resolver = Resolve(x => x.Metadata.GetPixelHeight()), Description = FieldDescriptions.AssetPixelHeight, DeprecationReason = "Use 'metadata' field instead." @@ -197,7 +197,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "type", - ResolvedType = AllTypes.NonNullAssetType, + ResolvedType = Scalars.NonNullAssetType, Resolver = Resolve(x => x.Type), Description = FieldDescriptions.AssetType }); @@ -205,7 +205,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "metadataText", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = Resolve(x => x.MetadataText), Description = FieldDescriptions.AssetMetadataText }); @@ -213,7 +213,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "tags", - ResolvedType = AllTypes.NonNullStrings, + ResolvedType = Scalars.NonNullStrings, Resolver = Resolve(x => x.TagNames), Description = FieldDescriptions.AssetTags }); @@ -222,7 +222,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets { Name = "metadata", Arguments = AssetActions.Metadata.Arguments, - ResolvedType = AllTypes.JsonNoop, + ResolvedType = Scalars.JsonNoop, Resolver = AssetActions.Metadata.Resolver, Description = FieldDescriptions.AssetMetadata }); @@ -230,7 +230,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "editToken", - ResolvedType = AllTypes.String, + ResolvedType = Scalars.String, Resolver = Resolve(x => x.EditToken), Description = FieldDescriptions.EditToken }); @@ -238,7 +238,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "sourceUrl", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = SourceUrl, Description = FieldDescriptions.AssetSourceUrl }); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetsResultGraphType.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetsResultGraphType.cs index ba8ff235b..1dcc50cb2 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetsResultGraphType.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetsResultGraphType.cs @@ -23,7 +23,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets AddField(new FieldType { Name = "total", - ResolvedType = AllTypes.NonNullInt, + ResolvedType = Scalars.NonNullInt, Resolver = ResolveList(x => x.Total), Description = FieldDescriptions.AssetsTotal }); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Builder.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Builder.cs index b5e61c336..bbfd1936d 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Builder.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Builder.cs @@ -36,6 +36,10 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types ValueConverter.Register(x => new Status(x)); } + public IInterfaceGraphType ContentInterface { get; } = new ContentInterfaceGraphType(); + + public IInterfaceGraphType ComponentInterface { get; } = new ComponentInterfaceGraphType(); + public Builder(IAppEntity app) { partitionResolver = app.PartitionResolver(); @@ -72,8 +76,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types Query = new AppQueriesGraphType(this, schemaInfos) }; - newSchema.RegisterType(SharedTypes.ComponentInterface); - newSchema.RegisterType(SharedTypes.ContentInterface); + newSchema.RegisterType(ComponentInterface); + newSchema.RegisterType(ContentInterface); newSchema.Directives.Register(SharedTypes.MemoryCacheDirective); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ComponentGraphType.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ComponentGraphType.cs index 017eb2052..60945084a 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ComponentGraphType.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ComponentGraphType.cs @@ -36,7 +36,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { Name = fieldInfo.FieldNameDynamic, Arguments = ContentActions.Json.Arguments, - ResolvedType = AllTypes.Json, + ResolvedType = Scalars.Json, Resolver = FieldVisitor.JsonPath, Description = fieldInfo.Field.RawProperties.Hints }).WithSourceName(fieldInfo); @@ -57,7 +57,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents } } - AddResolvedInterface(SharedTypes.ComponentInterface); + AddResolvedInterface(builder.ComponentInterface); } private static Func CheckType(string schemaId) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentActions.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentActions.cs index 962c6f761..bfd319ad9 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentActions.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentActions.cs @@ -26,7 +26,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { public static readonly QueryArguments Arguments = new QueryArguments { - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "path", Description = FieldDescriptions.JsonPath, @@ -51,7 +51,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly QueryArguments JsonPath = new QueryArguments { - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "path", Description = FieldDescriptions.JsonPath, @@ -63,13 +63,13 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { public static readonly QueryArguments Arguments = new QueryArguments { - new QueryArgument(AllTypes.NonNullString) + new QueryArgument(Scalars.NonNullString) { Name = "id", Description = FieldDescriptions.EntityId, DefaultValue = null }, - new QueryArgument(AllTypes.Int) + new QueryArgument(Scalars.Int) { Name = "version", Description = FieldDescriptions.QueryVersion, @@ -101,31 +101,31 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { public static readonly QueryArguments Arguments = new QueryArguments { - new QueryArgument(AllTypes.Int) + new QueryArgument(Scalars.Int) { Name = "top", Description = FieldDescriptions.QueryTop, DefaultValue = null }, - new QueryArgument(AllTypes.Int) + new QueryArgument(Scalars.Int) { Name = "skip", Description = FieldDescriptions.QuerySkip, DefaultValue = 0 }, - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "filter", Description = FieldDescriptions.QueryFilter, DefaultValue = null }, - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "orderby", Description = FieldDescriptions.QueryOrderBy, DefaultValue = null }, - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "search", Description = FieldDescriptions.QuerySearch, @@ -206,19 +206,19 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents Description = FieldDescriptions.ContentRequestData, DefaultValue = null }, - new QueryArgument(AllTypes.Boolean) + new QueryArgument(Scalars.Boolean) { Name = "publish", Description = FieldDescriptions.ContentRequestPublish, DefaultValue = false }, - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "status", Description = FieldDescriptions.ContentRequestOptionalStatus, DefaultValue = null }, - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "id", Description = FieldDescriptions.ContentRequestOptionalId, @@ -259,7 +259,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { return new QueryArguments { - new QueryArgument(AllTypes.NonNullString) + new QueryArgument(Scalars.NonNullString) { Name = "id", Description = FieldDescriptions.EntityId, @@ -271,25 +271,25 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents Description = FieldDescriptions.ContentRequestData, DefaultValue = null }, - new QueryArgument(AllTypes.Boolean) + new QueryArgument(Scalars.Boolean) { Name = "publish", Description = FieldDescriptions.ContentRequestPublish, DefaultValue = false }, - new QueryArgument(AllTypes.Boolean) + new QueryArgument(Scalars.Boolean) { Name = "patch", Description = FieldDescriptions.ContentRequestPatch, DefaultValue = false }, - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "status", Description = FieldDescriptions.ContentRequestOptionalStatus, DefaultValue = null }, - new QueryArgument(AllTypes.Int) + new QueryArgument(Scalars.Int) { Name = "expectedVersion", Description = FieldDescriptions.EntityExpectedVersion, @@ -326,7 +326,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { return new QueryArguments { - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "id", Description = FieldDescriptions.EntityId, @@ -338,7 +338,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents Description = FieldDescriptions.ContentRequestData, DefaultValue = null }, - new QueryArgument(AllTypes.Int) + new QueryArgument(Scalars.Int) { Name = "expectedVersion", Description = FieldDescriptions.EntityExpectedVersion, @@ -362,7 +362,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { return new QueryArguments { - new QueryArgument(AllTypes.String) + new QueryArgument(Scalars.String) { Name = "id", Description = FieldDescriptions.EntityId, @@ -374,7 +374,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents Description = FieldDescriptions.ContentRequestData, DefaultValue = null }, - new QueryArgument(AllTypes.Int) + new QueryArgument(Scalars.Int) { Name = "expectedVersion", Description = FieldDescriptions.EntityExpectedVersion, @@ -396,25 +396,25 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { public static readonly QueryArguments Arguments = new QueryArguments { - new QueryArgument(AllTypes.NonNullString) + new QueryArgument(Scalars.NonNullString) { Name = "id", Description = FieldDescriptions.EntityId, DefaultValue = null }, - new QueryArgument(AllTypes.NonNullString) + new QueryArgument(Scalars.NonNullString) { Name = "status", Description = FieldDescriptions.ContentRequestStatus, DefaultValue = null }, - new QueryArgument(AllTypes.DateTime) + new QueryArgument(Scalars.DateTime) { Name = "dueTime", Description = FieldDescriptions.ContentRequestDueTime, DefaultValue = null }, - new QueryArgument(AllTypes.Int) + new QueryArgument(Scalars.Int) { Name = "expectedVersion", Description = FieldDescriptions.EntityExpectedVersion, @@ -436,13 +436,13 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { public static readonly QueryArguments Arguments = new QueryArguments { - new QueryArgument(AllTypes.NonNullString) + new QueryArgument(Scalars.NonNullString) { Name = "id", Description = "The id of the content (usually GUID).", DefaultValue = null }, - new QueryArgument(AllTypes.Int) + new QueryArgument(Scalars.Int) { Name = "expectedVersion", Description = FieldDescriptions.EntityExpectedVersion, diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentFields.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentFields.cs index cd5a192c9..42b8a8ddc 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentFields.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentFields.cs @@ -38,7 +38,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType Id = new FieldType { Name = "id", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = EntityResolvers.Id, Description = FieldDescriptions.EntityId }; @@ -46,7 +46,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType Version = new FieldType { Name = "version", - ResolvedType = AllTypes.NonNullInt, + ResolvedType = Scalars.NonNullInt, Resolver = EntityResolvers.Version, Description = FieldDescriptions.EntityVersion }; @@ -54,7 +54,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType Created = new FieldType { Name = "created", - ResolvedType = AllTypes.NonNullDateTime, + ResolvedType = Scalars.NonNullDateTime, Resolver = EntityResolvers.Created, Description = FieldDescriptions.EntityCreated }; @@ -62,7 +62,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType CreatedBy = new FieldType { Name = "createdBy", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = EntityResolvers.CreatedBy, Description = FieldDescriptions.EntityCreatedBy }; @@ -78,7 +78,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType LastModified = new FieldType { Name = "lastModified", - ResolvedType = AllTypes.NonNullDateTime, + ResolvedType = Scalars.NonNullDateTime, Resolver = EntityResolvers.LastModified, Description = FieldDescriptions.EntityLastModified }; @@ -86,7 +86,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType LastModifiedBy = new FieldType { Name = "lastModifiedBy", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = EntityResolvers.LastModifiedBy, Description = FieldDescriptions.EntityLastModifiedBy }; @@ -102,7 +102,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType Status = new FieldType { Name = "status", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = Resolve(x => x.Status.ToString().ToUpperInvariant()), Description = FieldDescriptions.ContentStatus }; @@ -110,7 +110,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType StatusColor = new FieldType { Name = "statusColor", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = Resolve(x => x.StatusColor), Description = FieldDescriptions.ContentStatusColor }; @@ -118,7 +118,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType NewStatus = new FieldType { Name = "newStatus", - ResolvedType = AllTypes.String, + ResolvedType = Scalars.String, Resolver = Resolve(x => x.NewStatus?.ToString().ToUpperInvariant()), Description = FieldDescriptions.ContentNewStatus }; @@ -126,7 +126,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType NewStatusColor = new FieldType { Name = "newStatusColor", - ResolvedType = AllTypes.String, + ResolvedType = Scalars.String, Resolver = Resolve(x => x.NewStatusColor), Description = FieldDescriptions.ContentStatusColor }; @@ -134,7 +134,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType SchemaId = new FieldType { Name = "schemaId", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = Resolve(x => x[Component.Discriminator].ToString()), Description = FieldDescriptions.ContentSchemaId }; @@ -142,7 +142,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType Url = new FieldType { Name = "url", - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Resolver = ContentResolvers.Url, Description = FieldDescriptions.ContentUrl }; @@ -150,7 +150,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType EditToken = new FieldType { Name = "editToken", - ResolvedType = AllTypes.String, + ResolvedType = Scalars.String, Resolver = Resolve(x => x.EditToken), Description = FieldDescriptions.EditToken }; @@ -158,7 +158,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public static readonly FieldType StringFieldText = new FieldType { Name = "text", - ResolvedType = AllTypes.String, + ResolvedType = Scalars.String, Resolver = Resolvers.Sync(x => x), Description = FieldDescriptions.StringFieldText }; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentGraphType.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentGraphType.cs index b9a0b91c3..dd35308be 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentGraphType.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentGraphType.cs @@ -80,7 +80,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents AddReferencesQueries(builder, other); } - AddResolvedInterface(SharedTypes.ContentInterface); + AddResolvedInterface(builder.ContentInterface); Description = $"The structure of a {schemaInfo.DisplayName} content type."; } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentResultGraphType.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentResultGraphType.cs index 171b47b55..139797f69 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentResultGraphType.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentResultGraphType.cs @@ -21,7 +21,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents AddField(new FieldType { Name = "total", - ResolvedType = AllTypes.NonNullInt, + ResolvedType = Scalars.NonNullInt, Resolver = ContentResolvers.ListTotal, Description = FieldDescriptions.ContentsTotal }); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/DataFlatGraphType.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/DataFlatGraphType.cs index 5478fbf40..851319717 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/DataFlatGraphType.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/DataFlatGraphType.cs @@ -26,7 +26,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { Name = fieldInfo.FieldNameDynamic, Arguments = ContentActions.Json.Arguments, - ResolvedType = AllTypes.Json, + ResolvedType = Scalars.Json, Resolver = FieldVisitor.JsonPath, Description = fieldInfo.Field.RawProperties.Hints }).WithSourceName(fieldInfo); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/DataGraphType.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/DataGraphType.cs index adfcaa937..26919ee9c 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/DataGraphType.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/DataGraphType.cs @@ -37,7 +37,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { Name = partitionKey.EscapePartition(), Arguments = ContentActions.Json.Arguments, - ResolvedType = AllTypes.Json, + ResolvedType = Scalars.Json, Resolver = FieldVisitor.JsonPath, Description = fieldInfo.Field.RawProperties.Hints }).WithSourceName(partitionKey); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldInputVisitor.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldInputVisitor.cs index 7d545c5c5..200c85501 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldInputVisitor.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldInputVisitor.cs @@ -36,52 +36,52 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public IGraphType? Visit(IField field, FieldInfo args) { - return AllTypes.Strings; + return Scalars.Strings; } public IGraphType? Visit(IField field, FieldInfo args) { - return AllTypes.Boolean; + return Scalars.Boolean; } public IGraphType? Visit(IField field, FieldInfo args) { - return AllTypes.Json; + return Scalars.Json; } public IGraphType? Visit(IField field, FieldInfo args) { - return AllTypes.Json; + return Scalars.Json; } public IGraphType? Visit(IField field, FieldInfo args) { - return AllTypes.DateTime; + return Scalars.DateTime; } public IGraphType? Visit(IField field, FieldInfo args) { - return AllTypes.Json; + return Scalars.Json; } public IGraphType? Visit(IField field, FieldInfo args) { - return AllTypes.Json; + return Scalars.Json; } public IGraphType? Visit(IField field, FieldInfo args) { - return AllTypes.Strings; + return Scalars.Strings; } public IGraphType? Visit(IField field, FieldInfo args) { - return AllTypes.Float; + return Scalars.Float; } public IGraphType? Visit(IField field, FieldInfo args) { - var type = AllTypes.String; + var type = Scalars.String; if (field.Properties?.AllowedValues?.Count > 0 && field.Properties.CreateEnum) { @@ -98,7 +98,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public IGraphType? Visit(IField field, FieldInfo args) { - var type = AllTypes.Strings; + var type = Scalars.Strings; if (field.Properties?.AllowedValues?.Count > 0 && field.Properties.CreateEnum) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldVisitor.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldVisitor.cs index 81f946ade..b097d9068 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldVisitor.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldVisitor.cs @@ -126,7 +126,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public FieldGraphSchema Visit(IField field, FieldInfo args) { - return new (AllTypes.Boolean, JsonBoolean, null); + return new (Scalars.Boolean, JsonBoolean, null); } public FieldGraphSchema Visit(IField field, FieldInfo args) @@ -155,27 +155,27 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public FieldGraphSchema Visit(IField field, FieldInfo args) { - return new (AllTypes.DateTime, JsonDateTime, null); + return new (Scalars.DateTime, JsonDateTime, null); } public FieldGraphSchema Visit(IField field, FieldInfo args) { - return new (AllTypes.Json, JsonPath, ContentActions.Json.Arguments); + return new (Scalars.Json, JsonPath, ContentActions.Json.Arguments); } public FieldGraphSchema Visit(IField field, FieldInfo args) { - return new (AllTypes.Json, JsonPath, ContentActions.Json.Arguments); + return new (Scalars.Json, JsonPath, ContentActions.Json.Arguments); } public FieldGraphSchema Visit(IField field, FieldInfo args) { - return new (AllTypes.Float, JsonNumber, null); + return new (Scalars.Float, JsonNumber, null); } public FieldGraphSchema Visit(IField field, FieldInfo args) { - var type = AllTypes.String; + var type = Scalars.String; if (field.Properties.IsEmbeddable) { @@ -196,7 +196,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents public FieldGraphSchema Visit(IField field, FieldInfo args) { - var type = AllTypes.Strings; + var type = Scalars.Strings; if (field.Properties?.AllowedValues?.Count > 0 && field.Properties.CreateEnum) { diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/NestedGraphType.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/NestedGraphType.cs index ab76e94a6..e1110d9e4 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/NestedGraphType.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/NestedGraphType.cs @@ -26,7 +26,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents { Name = nestedFieldInfo.FieldNameDynamic, Arguments = ContentActions.Json.Arguments, - ResolvedType = AllTypes.Json, + ResolvedType = Scalars.Json, Resolver = FieldVisitor.JsonPath, Description = nestedFieldInfo.Field.RawProperties.Hints }).WithSourceName(nestedFieldInfo); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Primitives/EntitySavedGraphType.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Primitives/EntitySavedGraphType.cs index 235a1149e..e0b666722 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Primitives/EntitySavedGraphType.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Primitives/EntitySavedGraphType.cs @@ -26,7 +26,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Primitives { Name = "version", Resolver = ResolveVersion(), - ResolvedType = AllTypes.NonNullLong, + ResolvedType = Scalars.NonNullLong, Description = "The new version of the item." }); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AllTypes.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Scalars.cs similarity index 98% rename from backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AllTypes.cs rename to backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Scalars.cs index 8b8267e69..cdfb26a0f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AllTypes.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Scalars.cs @@ -11,7 +11,7 @@ using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Primitives; namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { - public static class AllTypes + public static class Scalars { public static readonly IGraphType Int = new IntGraphType(); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/SharedTypes.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/SharedTypes.cs index 970b76440..637716fc4 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/SharedTypes.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/SharedTypes.cs @@ -20,10 +20,6 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types public static readonly IGraphType AssetsResult = new AssetsResultGraphType(AssetsList); - public static readonly IInterfaceGraphType ContentInterface = new ContentInterfaceGraphType(); - - public static readonly IInterfaceGraphType ComponentInterface = new ComponentInterfaceGraphType(); - public static readonly CacheDirective MemoryCacheDirective = new CacheDirective(); public static readonly FieldType FindAsset = new FieldType diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/UserGraphType.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/UserGraphType.cs index 28e73ea27..6c45fe0c0 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/UserGraphType.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/UserGraphType.cs @@ -28,7 +28,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { Name = "id", Resolver = Resolve(x => x.Id), - ResolvedType = AllTypes.NonNullString, + ResolvedType = Scalars.NonNullString, Description = FieldDescriptions.UserId }); @@ -36,7 +36,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { Name = "displayName", Resolver = Resolve(x => x.Claims.DisplayName()), - ResolvedType = AllTypes.String, + ResolvedType = Scalars.String, Description = FieldDescriptions.UserDisplayName }); @@ -44,7 +44,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { Name = "email", Resolver = Resolve(x => x.Email), - ResolvedType = AllTypes.String, + ResolvedType = Scalars.String, Description = FieldDescriptions.UserEmail }); diff --git a/backend/src/Squidex/Squidex.csproj b/backend/src/Squidex/Squidex.csproj index d1cd2737c..7a667f2bd 100644 --- a/backend/src/Squidex/Squidex.csproj +++ b/backend/src/Squidex/Squidex.csproj @@ -109,10 +109,12 @@ + + @@ -125,15 +127,16 @@ + + -