diff --git a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AllTypes.cs b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AllTypes.cs index 18b9beff3..5e1b6c973 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AllTypes.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AllTypes.cs @@ -16,6 +16,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { public static readonly Type None = typeof(NoopGraphType); + public static readonly Type NonNullTagsType = typeof(NonNullGraphType>>); + public static readonly IGraphType Int = new IntGraphType(); public static readonly IGraphType Guid = new GuidGraphType2(); @@ -24,8 +26,6 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types public static readonly IGraphType Json = new JsonGraphType(); - public static readonly IGraphType Tags = new ListGraphType>(); - public static readonly IGraphType Float = new FloatGraphType(); public static readonly IGraphType Status = new EnumerationGraphType(); @@ -34,8 +34,6 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types public static readonly IGraphType Boolean = new BooleanGraphType(); - public static readonly IGraphType References = new ListGraphType>(); - public static readonly IGraphType NonNullInt = new NonNullGraphType(Int); public static readonly IGraphType NonNullGuid = new NonNullGraphType(Guid); 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 7ef69ecbd..bdb563a2b 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppQueriesGraphType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppQueriesGraphType.cs @@ -169,7 +169,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types { new QueryArgument(AllTypes.None) { - Name = "take", + Name = "top", Description = $"Optional number of assets to take (Default: {pageSize}).", DefaultValue = pageSize, ResolvedType = AllTypes.Int @@ -183,8 +183,15 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types }, new QueryArgument(AllTypes.None) { - Name = "search", - Description = "Optional query to limit the files by name.", + Name = "filter", + Description = "Optional OData filter.", + DefaultValue = string.Empty, + ResolvedType = AllTypes.String + }, + new QueryArgument(AllTypes.None) + { + Name = "orderby", + Description = "Optional OData order definition.", 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 23417373c..ecdcb3620 100644 --- a/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AssetGraphType.cs +++ b/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AssetGraphType.cs @@ -163,6 +163,15 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types Description = "The height of the image in pixels if the asset is an image." }); + AddField(new FieldType + { + Name = "tags", + ResolvedType = null, + Resolver = Resolve(x => x.Tags), + Description = "The height of the image in pixels if the asset is an image.", + Type = AllTypes.NonNullTagsType + }); + if (model.CanGenerateAssetSourceUrl) { AddField(new FieldType diff --git a/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLQueriesTests.cs b/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLQueriesTests.cs index 78798a6c1..06f6143eb 100644 --- a/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLQueriesTests.cs +++ b/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLQueriesTests.cs @@ -39,7 +39,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL { const string query = @" query { - queryAssets(search: ""my-query"", take: 30, skip: 5) { + queryAssets(filter: ""my-query"", top: 30, skip: 5) { id version created @@ -57,13 +57,14 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL isImage pixelWidth pixelHeight + tags slug } }"; var asset = CreateAsset(Guid.NewGuid()); - A.CallTo(() => assetQuery.QueryAsync(MatchsAssetContext(), A.That.Matches(x => x.ODataQuery == "?$take=30&$skip=5&$search=my-query"))) + A.CallTo(() => assetQuery.QueryAsync(MatchsAssetContext(), A.That.Matches(x => x.ODataQuery == "?$top=30&$skip=5&$filter=my-query"))) .Returns(ResultList.Create(0, asset)); var result = await sut.QueryAsync(context, new GraphQLQuery { Query = query }); @@ -93,6 +94,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL isImage = true, pixelWidth = 800, pixelHeight = 600, + tags = new string[] { "tag1", "tag2" }, slug = "myfile.png" } } @@ -107,7 +109,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL { const string query = @" query { - queryAssetsWithTotal(search: ""my-query"", take: 30, skip: 5) { + queryAssetsWithTotal(filter: ""my-query"", top: 30, skip: 5) { total items { id @@ -127,6 +129,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL isImage pixelWidth pixelHeight + tags slug } } @@ -134,7 +137,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL var asset = CreateAsset(Guid.NewGuid()); - A.CallTo(() => assetQuery.QueryAsync(MatchsAssetContext(), A.That.Matches(x => x.ODataQuery == "?$take=30&$skip=5&$search=my-query"))) + A.CallTo(() => assetQuery.QueryAsync(MatchsAssetContext(), A.That.Matches(x => x.ODataQuery == "?$top=30&$skip=5&$filter=my-query"))) .Returns(ResultList.Create(10, asset)); var result = await sut.QueryAsync(context, new GraphQLQuery { Query = query }); @@ -167,6 +170,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL isImage = true, pixelWidth = 800, pixelHeight = 600, + tags = new string[] { "tag1", "tag2" }, slug = "myfile.png" } } @@ -203,6 +207,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL isImage pixelWidth pixelHeight + tags slug }} }}"; @@ -235,6 +240,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL isImage = true, pixelWidth = 800, pixelHeight = 600, + tags = new string[] { "tag1", "tag2" }, slug = "myfile.png" } } diff --git a/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLTestBase.cs b/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLTestBase.cs index 40d612c10..9edd65708 100644 --- a/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLTestBase.cs +++ b/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLTestBase.cs @@ -177,7 +177,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL MimeType = "image/png", IsImage = true, PixelWidth = 800, - PixelHeight = 600 + PixelHeight = 600, + Tags = new[] { "tag1", "tag2" }.ToHashSet() }; return asset;