Skip to content

Commit 762a8c1

Browse files
committed
Add more tests
1 parent 79867e9 commit 762a8c1

21 files changed

+441
-23
lines changed

src/Our.Umbraco.GraphQL/Adapters/GraphTypeAdapter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ private QueryArgument CreateArgument(ParameterInfo parameterInfo)
214214
IGraphType inputType;
215215
if (unwrappedType == typeof(OrderBy))
216216
{
217-
var returnType = parameterInfo.Member.GetReturnType();
217+
var returnType = parameterInfo.Member.GetReturnType().Unwrap();
218+
218219
if (returnType.IsGenericType && returnType.GetGenericTypeDefinition() == typeof(Connection<>))
219220
returnType = returnType.GenericTypeArguments[0].GetTypeInfo();
220221

@@ -225,6 +226,7 @@ private QueryArgument CreateArgument(ParameterInfo parameterInfo)
225226
: Activator.CreateInstance(foundType);
226227

227228
inputType = new OrderByGraphType((IComplexGraphType) graphType);
229+
_visitor.Visit((EnumerationGraphType) inputType);
228230

229231
if (parameterType.IsGenericType && parameterType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
230232
{

src/Our.Umbraco.GraphQL/Adapters/PublishedContent/Types/ContentVariationGraphType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class ContentVariationGraphType : EnumerationGraphType<ContentVariation>
1212
public ContentVariationGraphType()
1313
{
1414
Name = TypeName;
15+
Description = "Indicates how values can vary.";
1516
}
1617
}
1718
}

src/Our.Umbraco.GraphQL/Adapters/PublishedContent/Types/PublishedItemTypeGraphType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class PublishedItemTypeGraphType : EnumerationGraphType<PublishedItemType
1212
public PublishedItemTypeGraphType()
1313
{
1414
Name = TypeName;
15+
Description = "The type of published element.";
1516
}
1617
}
1718
}

src/Our.Umbraco.GraphQL/Adapters/PublishedContent/Types/UrlModeGraphType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class UrlModeGraphType : EnumerationGraphType<UrlMode>
1212
public UrlModeGraphType()
1313
{
1414
Name = TypeName;
15+
Description = "Specifies the type of urls that the url provider should produce, Auto is the default.";
1516
}
1617
}
1718
}

src/Our.Umbraco.GraphQL/Adapters/PublishedContent/Visitors/PublishedContentVisitor.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public override void Visit(ISchema schema)
105105
}
106106
}
107107

108-
private void CreateContentField<T>(ObjectGraphType<T> query, IComplexGraphType graphType,
108+
private void CreateContentField<T>(ComplexGraphType<T> query, IComplexGraphType graphType,
109109
IPublishedContentType publishedContentType,
110110
Func<IPublishedContentCache, string, IEnumerable<IPublishedContent>> fetch)
111111
{
@@ -114,15 +114,18 @@ private void CreateContentField<T>(ObjectGraphType<T> query, IComplexGraphType g
114114
.Bidirectional()
115115
.Resolve(ctx =>
116116
{
117-
var items = fetch(_publishedSnapshotAccessor.PublishedSnapshot.Content, ctx.GetArgument<string>("culture")).ToList();
117+
var items = fetch(_publishedSnapshotAccessor.PublishedSnapshot.Content,
118+
ctx.GetArgument<string>("culture")).ToList();
118119

119120
return items.OrderBy(ctx.GetArgument<IEnumerable<OrderBy>>("orderBy"))
120-
.ToConnection(x => x.Key, ctx.First, ctx.After, ctx.Last, ctx.Before, items.Count);
121+
.ToConnection(x => x.Key, ctx.First, ctx.After, ctx.Last, ctx.Before, items.Count);
121122
});
122123

123124
var connectionField = query.GetField(publishedContentType.Alias);
124125
connectionField.ResolvedType = new ConnectionGraphType(graphType);
125-
connectionField.Arguments.Add(new QueryArgument(new ListGraphType(new NonNullGraphType(new OrderByGraphType(graphType)))) { Name = "orderBy" });
126+
connectionField.Arguments.Add(
127+
new QueryArgument(new ListGraphType(new NonNullGraphType(new OrderByGraphType(graphType))))
128+
{Name = "orderBy"});
126129
}
127130
}
128131
}

src/Our.Umbraco.GraphQL/Adapters/Types/IdGraphType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public override object ParseValue(object value)
1010
var parsed = base.ParseValue(value);
1111
return parsed == null ? (Id?)null : new Id(parsed.ToString());
1212
}
13+
1314
public override object ParseLiteral(IValue value)
1415
{
1516
var parsed = base.ParseLiteral(value);

src/Our.Umbraco.GraphQL/Adapters/Types/UdiGraphType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class UdiGraphType : ScalarGraphType
88
{
99
public UdiGraphType()
1010
{
11-
Name = "Udi";
11+
Name = "UDI";
1212
Description = "Represents an entity identifier.";
1313
}
1414

src/Our.Umbraco.GraphQL/Compose/GraphQLComposer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Newtonsoft.Json;
1313
using Our.Umbraco.GraphQL.Adapters.PublishedContent.Visitors;
1414
using GraphQL.DataLoader;
15+
using Our.Umbraco.GraphQL.FieldMiddleware;
1516
using Our.Umbraco.GraphQL.Middleware;
1617

1718
namespace Our.Umbraco.GraphQL.Compose

src/Our.Umbraco.GraphQL/Middleware/EnsureHttpContextFieldMiddleware.cs renamed to src/Our.Umbraco.GraphQL/FieldMiddleware/EnsureHttpContextFieldMiddleware.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
using System.Web;
33
using GraphQL.Instrumentation;
44
using GraphQL.Types;
5+
using Our.Umbraco.GraphQL.Middleware;
56
using Umbraco.Web;
67

7-
namespace Our.Umbraco.GraphQL.Middleware
8+
namespace Our.Umbraco.GraphQL.FieldMiddleware
89
{
910
internal class EnsureHttpContextFieldMiddleware : IFieldMiddleware
1011
{
File renamed without changes.

0 commit comments

Comments
 (0)