|
10 | 10 | using NSubstitute;
|
11 | 11 | using Our.Umbraco.GraphQL.Adapters;
|
12 | 12 | using Our.Umbraco.GraphQL.Adapters.Resolvers;
|
| 13 | +using Our.Umbraco.GraphQL.Adapters.Types; |
13 | 14 | using Our.Umbraco.GraphQL.Adapters.Types.Relay;
|
14 | 15 | using Our.Umbraco.GraphQL.Adapters.Types.Resolution;
|
15 | 16 | using Our.Umbraco.GraphQL.Adapters.Visitors;
|
@@ -981,6 +982,36 @@ public void Adapt_MethodCancellationToken_ArgumentIsNotAdded()
|
981 | 982 | .Which.Arguments.Should().NotContain(x => x.Name == "cancellationToken");
|
982 | 983 | }
|
983 | 984 |
|
| 985 | + [Fact] |
| 986 | + public void Adapt_MethodWithOrderByArgument_ArgumentIsAdded() |
| 987 | + { |
| 988 | + var adapter = CreateSUT(); |
| 989 | + |
| 990 | + var graphType = adapter.Adapt<ClassWithName>(); |
| 991 | + |
| 992 | + graphType.Should().BeAssignableTo<IObjectGraphType>() |
| 993 | + .Which.Fields.Should().Contain(x => x.Name == nameof(ClassWithName.HasOrderByArgument)) |
| 994 | + .Which.Arguments.Should().Contain(x => x.Name == "orderBy") |
| 995 | + .Which.ResolvedType.Should().BeAssignableTo<ListGraphType>() |
| 996 | + .Which.ResolvedType.Should().BeAssignableTo<NonNullGraphType>() |
| 997 | + .Which.ResolvedType.Should().BeAssignableTo<OrderByGraphType>(); |
| 998 | + } |
| 999 | + |
| 1000 | + [Fact] |
| 1001 | + public void Adapt_MethodReturnTypeIsConnectionHasOrderByArgument_ArgumentIsAdded() |
| 1002 | + { |
| 1003 | + var adapter = CreateSUT(); |
| 1004 | + |
| 1005 | + var graphType = adapter.Adapt<ClassWithName>(); |
| 1006 | + |
| 1007 | + graphType.Should().BeAssignableTo<IObjectGraphType>() |
| 1008 | + .Which.Fields.Should().Contain(x => x.Name == nameof(ClassWithName.ConnectionWithOrderByArgument)) |
| 1009 | + .Which.Arguments.Should().Contain(x => x.Name == "orderBy") |
| 1010 | + .Which.ResolvedType.Should().BeAssignableTo<ListGraphType>() |
| 1011 | + .Which.ResolvedType.Should().BeAssignableTo<NonNullGraphType>() |
| 1012 | + .Which.ResolvedType.Should().BeAssignableTo<OrderByGraphType>(); |
| 1013 | + } |
| 1014 | + |
984 | 1015 | private abstract class AbstractClassWithoutDescription
|
985 | 1016 | {
|
986 | 1017 | public string PublicField;
|
@@ -1121,6 +1152,12 @@ private class ClassWithName
|
1121 | 1152 |
|
1122 | 1153 | public Task<IEnumerable<ClassWithDescription>> TaskEnumerableDescriptions() =>
|
1123 | 1154 | Task.FromResult(Enumerable.Empty<ClassWithDescription>());
|
| 1155 | + |
| 1156 | + public IEnumerable<ClassWithDescription> HasOrderByArgument(IEnumerable<OrderBy> orderBy = null) => |
| 1157 | + Enumerable.Empty<ClassWithDescription>(); |
| 1158 | + |
| 1159 | + public Connection<ClassWithDescription> ConnectionWithOrderByArgument(IEnumerable<OrderBy> orderBy = null) => |
| 1160 | + null; |
1124 | 1161 | }
|
1125 | 1162 |
|
1126 | 1163 | [Name("MyEnum")]
|
@@ -1154,6 +1191,7 @@ private class ClassWithDescription
|
1154 | 1191 |
|
1155 | 1192 | [Attributes.Description("Property description.")]
|
1156 | 1193 | public string PropertyWithDescription { get; set; }
|
| 1194 | + |
1157 | 1195 | [Attributes.Description("Method description.")]
|
1158 | 1196 | public string MethodWithDescription() => null;
|
1159 | 1197 |
|
|
0 commit comments