From bc130340cb6b837dd7f2fd2fa03b6ac54ad39b72 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Wed, 17 Jan 2018 11:17:05 +0100 Subject: [PATCH] Minor optimizations. --- .../Contents/GraphQL/GraphQLModel.cs | 34 +++++----- .../Contents/GraphQL/Types/AllTypes.cs | 67 +++++++++++++++++++ .../GraphQL/Types/AppMutationsGraphType.cs | 64 ++++++++++-------- .../GraphQL/Types/AppQueriesGraphType.cs | 50 ++++++++------ .../Contents/GraphQL/Types/AssetGraphType.cs | 34 +++++----- .../GraphQL/Types/AssetsResultGraphType.cs | 2 +- .../GraphQL/Types/CommandVersionGraphType.cs | 2 +- .../ContentDataChangedResultGraphType.cs | 2 +- .../Types/ContentDataGraphInputType.cs | 3 +- .../GraphQL/Types/ContentDataGraphType.cs | 3 +- .../GraphQL/Types/ContentGraphType.cs | 16 ++--- .../GraphQL/Types/ContentsResultGraphType.cs | 2 +- .../Types/GeolocationInputGraphType.cs | 4 +- 13 files changed, 185 insertions(+), 98 deletions(-) create mode 100644 src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AllTypes.cs diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLModel.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLModel.cs index 0c8082a31..03ceeec54 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLModel.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLModel.cs @@ -54,35 +54,35 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL { { typeof(StringField), - new StringGraphType() + AllTypes.String }, { typeof(BooleanField), - new BooleanGraphType() + AllTypes.Boolean }, { typeof(NumberField), - new FloatGraphType() + AllTypes.Boolean }, { typeof(DateTimeField), - new DateGraphType() + AllTypes.Date }, { typeof(GeolocationField), - new GeolocationInputGraphType() + AllTypes.GeolocationInput }, { typeof(TagsField), - new ListGraphType(new StringGraphType()) + AllTypes.ListOfNonNullString }, { typeof(AssetsField), - new ListGraphType(new GuidGraphType()) + AllTypes.ListOfNonNullGuid }, { typeof(ReferencesField), - new ListGraphType(new GuidGraphType()) + AllTypes.ListOfNonNullGuid } }; @@ -90,31 +90,31 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL { { typeof(StringField), - field => ResolveDefault("String") + field => ResolveDefault(AllTypes.NoopString) }, { typeof(BooleanField), - field => ResolveDefault("Boolean") + field => ResolveDefault(AllTypes.NoopBoolean) }, { typeof(NumberField), - field => ResolveDefault("Float") + field => ResolveDefault(AllTypes.NoopFloat) }, { typeof(DateTimeField), - field => ResolveDefault("Date") + field => ResolveDefault(AllTypes.NoopDate) }, { typeof(JsonField), - field => ResolveDefault("Json") + field => ResolveDefault(AllTypes.NoopJson) }, { typeof(GeolocationField), - field => ResolveDefault("Geolocation") + field => ResolveDefault(AllTypes.NoopGeolocation) }, { typeof(TagsField), - field => ResolveDefault("String") + field => ResolveDefault(AllTypes.NoopTags) }, { typeof(AssetsField), @@ -144,9 +144,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } } - private static (IGraphType ResolveType, IFieldResolver Resolver) ResolveDefault(string name) + private static (IGraphType ResolveType, IFieldResolver Resolver) ResolveDefault(IGraphType type) { - return (new NoopGraphType(name), new FuncFieldResolver(c => c.Source.GetOrDefault(c.FieldName))); + return (type, new FuncFieldResolver(c => c.Source.GetOrDefault(c.FieldName))); } public IFieldResolver ResolveAssetUrl() diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AllTypes.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AllTypes.cs new file mode 100644 index 000000000..dac8e7e07 --- /dev/null +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AllTypes.cs @@ -0,0 +1,67 @@ +// ========================================================================== +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex UG (haftungsbeschraenkt) +// All rights reserved. Licensed under the MIT license. +// ========================================================================== + +using System; +using GraphQL.Types; + +namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types +{ + public static class AllTypes + { + public static readonly Type None = typeof(NoopGraphType); + + public static readonly IGraphType Int = new IntGraphType(); + + public static readonly IGraphType Guid = new GuidGraphType(); + + public static readonly IGraphType Date = new DateGraphType(); + + public static readonly IGraphType Float = new FloatGraphType(); + + public static readonly IGraphType String = new StringGraphType(); + + public static readonly IGraphType Boolean = new BooleanGraphType(); + + public static readonly IGraphType NonNullInt = new NonNullGraphType(new IntGraphType()); + + public static readonly IGraphType NonNullGuid = new NonNullGraphType(new GuidGraphType()); + + public static readonly IGraphType NonNullDate = new NonNullGraphType(new DateGraphType()); + + public static readonly IGraphType NonNullFloat = new NonNullGraphType(new FloatGraphType()); + + public static readonly IGraphType NonNullString = new NonNullGraphType(new StringGraphType()); + + public static readonly IGraphType NonNullBoolean = new NonNullGraphType(new BooleanGraphType()); + + public static readonly IGraphType ListOfNonNullGuid = new ListGraphType(new NonNullGraphType(new GuidGraphType())); + + public static readonly IGraphType ListOfNonNullString = new ListGraphType(new NonNullGraphType(new StringGraphType())); + + public static readonly IGraphType NoopInt = new NoopGraphType("Int"); + + public static readonly IGraphType NoopGuid = new NoopGraphType("Guid"); + + public static readonly IGraphType NoopDate = new NoopGraphType("Date"); + + public static readonly IGraphType NoopJson = new NoopGraphType("Json"); + + public static readonly IGraphType NoopTags = new NoopGraphType("Tags"); + + public static readonly IGraphType NoopFloat = new NoopGraphType("Float"); + + public static readonly IGraphType NoopString = new NoopGraphType("String"); + + public static readonly IGraphType NoopBoolean = new NoopGraphType("Boolean"); + + public static readonly IGraphType NoopGeolocation = new NoopGraphType("Geolocation"); + + public static readonly IGraphType CommandVersion = new CommandVersionGraphType(); + + public static readonly IGraphType GeolocationInput = new GeolocationInputGraphType(); + } +} diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppMutationsGraphType.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppMutationsGraphType.cs index a4a9e8d7d..93275e729 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppMutationsGraphType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppMutationsGraphType.cs @@ -56,24 +56,26 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types Name = $"create{schemaType}Content", Arguments = new QueryArguments { - new QueryArgument(typeof(BooleanGraphType)) - { - Name = "publish", - Description = "Set to true to autopublish content.", - DefaultValue = false - }, - new QueryArgument(typeof(NoopGraphType)) + new QueryArgument(AllTypes.None) { Name = "data", Description = $"The data for the {schemaName} content.", DefaultValue = null, ResolvedType = new NonNullGraphType(inputType), }, - new QueryArgument(typeof(IntGraphType)) + new QueryArgument(AllTypes.None) + { + Name = "publish", + Description = "Set to true to autopublish content.", + DefaultValue = false, + ResolvedType = AllTypes.Boolean + }, + new QueryArgument(AllTypes.None) { Name = "expectedVersion", Description = "The expected version", - DefaultValue = EtagVersion.Any + DefaultValue = EtagVersion.Any, + ResolvedType = AllTypes.Int } }, ResolvedType = new NonNullGraphType(contentType), @@ -102,24 +104,26 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types Name = $"update{schemaType}Content", Arguments = new QueryArguments { - new QueryArgument(typeof(NonNullGraphType)) + new QueryArgument(AllTypes.None) { Name = "id", Description = $"The id of the {schemaName} content (GUID)", - DefaultValue = string.Empty + DefaultValue = string.Empty, + ResolvedType = AllTypes.NonNullGuid }, - new QueryArgument(typeof(NoopGraphType)) + new QueryArgument(AllTypes.None) { Name = "data", Description = $"The data for the {schemaName} content.", DefaultValue = null, ResolvedType = new NonNullGraphType(inputType), }, - new QueryArgument(typeof(IntGraphType)) + new QueryArgument(AllTypes.None) { Name = "expectedVersion", Description = "The expected version", - DefaultValue = EtagVersion.Any + DefaultValue = EtagVersion.Any, + ResolvedType = AllTypes.Int } }, ResolvedType = new NonNullGraphType(resultType), @@ -146,24 +150,26 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types Name = $"patch{schemaType}Content", Arguments = new QueryArguments { - new QueryArgument(typeof(NonNullGraphType)) + new QueryArgument(AllTypes.None) { Name = "id", Description = $"The id of the {schemaName} content (GUID)", - DefaultValue = string.Empty + DefaultValue = string.Empty, + ResolvedType = AllTypes.NonNullGuid }, - new QueryArgument(typeof(NoopGraphType)) + new QueryArgument(AllTypes.None) { Name = "data", Description = $"The data for the {schemaName} content.", DefaultValue = null, ResolvedType = new NonNullGraphType(inputType), }, - new QueryArgument(typeof(IntGraphType)) + new QueryArgument(AllTypes.None) { Name = "expectedVersion", Description = "The expected version", - DefaultValue = EtagVersion.Any + DefaultValue = EtagVersion.Any, + ResolvedType = AllTypes.Int } }, ResolvedType = new NonNullGraphType(resultType), @@ -189,7 +195,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { Name = $"publish{schemaType}Content", Arguments = CreateIdArguments(schemaName), - ResolvedType = new NonNullGraphType(new CommandVersionGraphType()), + ResolvedType = AllTypes.CommandVersion, Resolver = ResolveAsync((c, publish) => { var contentId = c.GetArgument("id"); @@ -208,7 +214,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { Name = $"unpublish{schemaType}Content", Arguments = CreateIdArguments(schemaName), - ResolvedType = new NonNullGraphType(new CommandVersionGraphType()), + ResolvedType = AllTypes.CommandVersion, Resolver = ResolveAsync((c, publish) => { var contentId = c.GetArgument("id"); @@ -227,7 +233,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { Name = $"archive{schemaType}Content", Arguments = CreateIdArguments(schemaName), - ResolvedType = new NonNullGraphType(new CommandVersionGraphType()), + ResolvedType = AllTypes.CommandVersion, Resolver = ResolveAsync((c, publish) => { var contentId = c.GetArgument("id"); @@ -246,7 +252,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { Name = $"restore{schemaType}Content", Arguments = CreateIdArguments(schemaName), - ResolvedType = new NonNullGraphType(new CommandVersionGraphType()), + ResolvedType = AllTypes.CommandVersion, Resolver = ResolveAsync((c, publish) => { var contentId = c.GetArgument("id"); @@ -265,7 +271,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { Name = $"delete{schemaType}Content", Arguments = CreateIdArguments(schemaName), - ResolvedType = new NonNullGraphType(new CommandVersionGraphType()), + ResolvedType = AllTypes.CommandVersion, Resolver = ResolveAsync((c, publish) => { var contentId = c.GetArgument("id"); @@ -282,17 +288,19 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { return new QueryArguments { - new QueryArgument(typeof(GuidGraphType)) + new QueryArgument(AllTypes.None) { Name = "id", Description = $"The id of the {schemaName} content (GUID)", - DefaultValue = string.Empty + DefaultValue = string.Empty, + ResolvedType = AllTypes.NonNullGuid }, - new QueryArgument(typeof(IntGraphType)) + new QueryArgument(AllTypes.None) { Name = "expectedVersion", Description = "The expected version", - DefaultValue = EtagVersion.Any + DefaultValue = EtagVersion.Any, + ResolvedType = AllTypes.Int } }; } diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppQueriesGraphType.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppQueriesGraphType.cs index 06734c014..40c64fdbf 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppQueriesGraphType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppQueriesGraphType.cs @@ -143,11 +143,12 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { return new QueryArguments { - new QueryArgument(typeof(NonNullGraphType)) + new QueryArgument(AllTypes.None) { Name = "id", Description = "The id of the asset (GUID).", - DefaultValue = string.Empty + DefaultValue = string.Empty, + ResolvedType = AllTypes.NonNullGuid } }; } @@ -156,11 +157,12 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { return new QueryArguments { - new QueryArgument(typeof(NonNullGraphType)) + new QueryArgument(AllTypes.None) { Name = "id", Description = $"The id of the {schemaName} content (GUID)", - DefaultValue = string.Empty + DefaultValue = string.Empty, + ResolvedType = AllTypes.NonNullGuid } }; } @@ -169,23 +171,26 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { return new QueryArguments { - new QueryArgument(typeof(IntGraphType)) + new QueryArgument(AllTypes.None) { Name = "take", Description = "Optional number of assets to take (Default: 20).", - DefaultValue = 20 + DefaultValue = 20, + ResolvedType = AllTypes.Int }, - new QueryArgument(typeof(IntGraphType)) + new QueryArgument(AllTypes.None) { Name = "skip", Description = "Optional number of assets to skip.", - DefaultValue = 0 + DefaultValue = 0, + ResolvedType = AllTypes.Int }, - new QueryArgument(typeof(StringGraphType)) + new QueryArgument(AllTypes.None) { Name = "search", Description = "Optional query to limit the files by name.", - DefaultValue = string.Empty + DefaultValue = string.Empty, + ResolvedType = AllTypes.String } }; } @@ -194,35 +199,40 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { return new QueryArguments { - new QueryArgument(typeof(IntGraphType)) + new QueryArgument(AllTypes.None) { Name = "top", Description = "Optional number of contents to take (Default: 20).", - DefaultValue = 20 + DefaultValue = 20, + ResolvedType = AllTypes.Int }, - new QueryArgument(typeof(IntGraphType)) + new QueryArgument(AllTypes.None) { Name = "skip", Description = "Optional number of contents to skip.", - DefaultValue = 0 + DefaultValue = 0, + ResolvedType = AllTypes.Int }, - new QueryArgument(typeof(StringGraphType)) + new QueryArgument(AllTypes.None) { Name = "filter", Description = "Optional OData filter.", - DefaultValue = string.Empty + DefaultValue = string.Empty, + ResolvedType = AllTypes.String }, - new QueryArgument(typeof(StringGraphType)) + new QueryArgument(AllTypes.None) { Name = "search", Description = "Optional OData full text search.", - DefaultValue = string.Empty + DefaultValue = string.Empty, + ResolvedType = AllTypes.String }, - new QueryArgument(typeof(StringGraphType)) + new QueryArgument(AllTypes.None) { Name = "orderby", Description = "Optional OData order definition.", - DefaultValue = string.Empty + DefaultValue = string.Empty, + ResolvedType = AllTypes.String } }; } diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AssetGraphType.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AssetGraphType.cs index 9c2ade9ab..47e32ed04 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AssetGraphType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AssetGraphType.cs @@ -22,7 +22,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "id", - ResolvedType = new NonNullGraphType(new StringGraphType()), + ResolvedType = AllTypes.NonNullGuid, Resolver = Resolve(x => x.Id.ToString()), Description = "The id of the asset." }); @@ -30,7 +30,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "version", - ResolvedType = new NonNullGraphType(new IntGraphType()), + ResolvedType = AllTypes.NonNullInt, Resolver = Resolve(x => x.Version), Description = "The version of the asset." }); @@ -38,7 +38,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "created", - ResolvedType = new NonNullGraphType(new DateGraphType()), + ResolvedType = AllTypes.NonNullDate, Resolver = Resolve(x => x.Created.ToDateTimeUtc()), Description = "The date and time when the asset has been created." }); @@ -46,7 +46,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "createdBy", - ResolvedType = new NonNullGraphType(new StringGraphType()), + ResolvedType = AllTypes.NonNullString, Resolver = Resolve(x => x.CreatedBy.ToString()), Description = "The user that has created the asset." }); @@ -54,7 +54,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "lastModified", - ResolvedType = new NonNullGraphType(new DateGraphType()), + ResolvedType = AllTypes.NonNullDate, Resolver = Resolve(x => x.LastModified.ToDateTimeUtc()), Description = "The date and time when the asset has been modified last." }); @@ -62,7 +62,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "lastModifiedBy", - ResolvedType = new NonNullGraphType(new StringGraphType()), + ResolvedType = AllTypes.NonNullString, Resolver = Resolve(x => x.LastModifiedBy.ToString()), Description = "The user that has updated the asset last." }); @@ -70,7 +70,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "mimeType", - ResolvedType = new NonNullGraphType(new StringGraphType()), + ResolvedType = AllTypes.NonNullString, Resolver = Resolve(x => x.MimeType), Description = "The mime type." }); @@ -78,7 +78,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "url", - ResolvedType = new NonNullGraphType(new StringGraphType()), + ResolvedType = AllTypes.NonNullString, Resolver = model.ResolveAssetUrl(), Description = "The url to the asset." }); @@ -86,7 +86,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "thumbnailUrl", - ResolvedType = new StringGraphType(), + ResolvedType = AllTypes.String, Resolver = model.ResolveAssetThumbnailUrl(), Description = "The thumbnail url to the asset." }); @@ -94,7 +94,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "fileName", - ResolvedType = new NonNullGraphType(new StringGraphType()), + ResolvedType = AllTypes.NonNullString, Resolver = Resolve(x => x.FileName), Description = "The file name." }); @@ -102,7 +102,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "fileType", - ResolvedType = new NonNullGraphType(new StringGraphType()), + ResolvedType = AllTypes.NonNullString, Resolver = Resolve(x => x.FileName.FileType()), Description = "The file type." }); @@ -110,7 +110,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "fileSize", - ResolvedType = new NonNullGraphType(new IntGraphType()), + ResolvedType = AllTypes.NonNullInt, Resolver = Resolve(x => x.FileSize), Description = "The size of the file in bytes." }); @@ -118,7 +118,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "fileVersion", - ResolvedType = new NonNullGraphType(new IntGraphType()), + ResolvedType = AllTypes.NonNullInt, Resolver = Resolve(x => x.FileVersion), Description = "The version of the file." }); @@ -126,7 +126,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "isImage", - ResolvedType = new NonNullGraphType(new BooleanGraphType()), + ResolvedType = AllTypes.NonNullBoolean, Resolver = Resolve(x => x.IsImage), Description = "Determines of the created file is an image." }); @@ -134,7 +134,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "pixelWidth", - ResolvedType = new IntGraphType(), + ResolvedType = AllTypes.Int, Resolver = Resolve(x => x.PixelWidth), Description = "The width of the image in pixels if the asset is an image." }); @@ -142,7 +142,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "pixelHeight", - ResolvedType = new IntGraphType(), + ResolvedType = AllTypes.Int, Resolver = Resolve(x => x.PixelHeight), Description = "The height of the image in pixels if the asset is an image." }); @@ -152,7 +152,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "sourceUrl", - ResolvedType = new StringGraphType(), + ResolvedType = AllTypes.NonNullString, Resolver = model.ResolveAssetSourceUrl(), Description = "The source url of the asset." }); diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AssetsResultGraphType.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AssetsResultGraphType.cs index 1114e70a3..b86685071 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AssetsResultGraphType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AssetsResultGraphType.cs @@ -22,8 +22,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "total", + ResolvedType = AllTypes.Int, Resolver = Resolve(x => x.Total), - ResolvedType = new NonNullGraphType(new IntGraphType()), Description = $"The total count of assets." }); diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/CommandVersionGraphType.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/CommandVersionGraphType.cs index dd29901d8..9fdc792f2 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/CommandVersionGraphType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/CommandVersionGraphType.cs @@ -20,7 +20,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "version", - ResolvedType = new IntGraphType(), + ResolvedType = AllTypes.Int, Resolver = ResolveVersion(), Description = "The new version of the item." }); diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataChangedResultGraphType.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataChangedResultGraphType.cs index 1c9e6e822..ebe00aadb 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataChangedResultGraphType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataChangedResultGraphType.cs @@ -20,7 +20,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "version", - ResolvedType = new IntGraphType(), + ResolvedType = AllTypes.Int, Resolver = Resolve(x => x.Version), Description = $"The new version of the {schemaName} content." }); diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataGraphInputType.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataGraphInputType.cs index 440ea753a..42512c861 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataGraphInputType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataGraphInputType.cs @@ -62,7 +62,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { Name = field.Name.ToCamelCase(), Resolver = fieldResolver, - ResolvedType = fieldGraphType + ResolvedType = fieldGraphType, + Description = $"The {fieldName} field." }); } } diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataGraphType.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataGraphType.cs index b9822826b..d74c6e383 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataGraphType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataGraphType.cs @@ -57,7 +57,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { Name = field.Name.ToCamelCase(), Resolver = fieldResolver, - ResolvedType = fieldGraphType + ResolvedType = fieldGraphType, + Description = $"The {fieldName} field." }); } } diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentGraphType.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentGraphType.cs index b8dc4b304..c23eaeaea 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentGraphType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentGraphType.cs @@ -25,15 +25,15 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "id", - ResolvedType = new NonNullGraphType(new StringGraphType()), - Resolver = Resolve(x => x.Id.ToString()), + ResolvedType = AllTypes.NonNullGuid, + Resolver = Resolve(x => x.Id), Description = $"The id of the {schemaName} content." }); AddField(new FieldType { Name = "version", - ResolvedType = new NonNullGraphType(new IntGraphType()), + ResolvedType = AllTypes.NonNullInt, Resolver = Resolve(x => x.Version), Description = $"The version of the {schemaName} content." }); @@ -41,7 +41,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "created", - ResolvedType = new NonNullGraphType(new DateGraphType()), + ResolvedType = AllTypes.NonNullDate, Resolver = Resolve(x => x.Created.ToDateTimeUtc()), Description = $"The date and time when the {schemaName} content has been created." }); @@ -49,7 +49,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "createdBy", - ResolvedType = new NonNullGraphType(new StringGraphType()), + ResolvedType = AllTypes.NonNullString, Resolver = Resolve(x => x.CreatedBy.ToString()), Description = $"The user that has created the {schemaName} content." }); @@ -57,7 +57,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "lastModified", - ResolvedType = new NonNullGraphType(new DateGraphType()), + ResolvedType = AllTypes.NonNullDate, Resolver = Resolve(x => x.LastModified.ToDateTimeUtc()), Description = $"The date and time when the {schemaName} content has been modified last." }); @@ -65,7 +65,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "lastModifiedBy", - ResolvedType = new NonNullGraphType(new StringGraphType()), + ResolvedType = AllTypes.NonNullString, Resolver = Resolve(x => x.LastModifiedBy.ToString()), Description = $"The user that has updated the {schemaName} content last." }); @@ -73,7 +73,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "url", - ResolvedType = new NonNullGraphType(new StringGraphType()), + ResolvedType = AllTypes.NonNullString, Resolver = model.ResolveContentUrl(schema), Description = $"The url to the the {schemaName} content." }); diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentsResultGraphType.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentsResultGraphType.cs index c8992e252..c3c052d06 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentsResultGraphType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentsResultGraphType.cs @@ -22,7 +22,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { Name = "total", Resolver = Resolver(x => x.Total), - ResolvedType = new NonNullGraphType(new IntGraphType()), + ResolvedType = AllTypes.NonNullInt, Description = $"The total number of {schemaName} items." }); diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/GeolocationInputGraphType.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/GeolocationInputGraphType.cs index 6de8c1405..73ba49b5c 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/GeolocationInputGraphType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/GeolocationInputGraphType.cs @@ -18,13 +18,13 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types AddField(new FieldType { Name = "latitude", - ResolvedType = new NonNullGraphType(new FloatGraphType()) + ResolvedType = AllTypes.NonNullFloat }); AddField(new FieldType { Name = "longitude", - ResolvedType = new NonNullGraphType(new FloatGraphType()) + ResolvedType = AllTypes.NonNullFloat }); } }