Skip to content

Commit 3d8d45d

Browse files
Compiling against 9.0.0
1 parent 1a73d49 commit 3d8d45d

File tree

12 files changed

+64
-20
lines changed

12 files changed

+64
-20
lines changed

samples/Website/Startup.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
6262
app.UseUmbraco()
6363
.WithMiddleware(u =>
6464
{
65-
u.WithBackOffice();
66-
u.WithWebsite();
65+
u.UseBackOffice();
66+
u.UseWebsite();
6767
})
6868
.WithEndpoints(u =>
6969
{

samples/Website/Website.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
</PropertyGroup>
55

66
<ItemGroup>
7-
<PackageReference Include="Umbraco.Cms" Version="9.0.0-beta003" />
8-
<PackageReference Include="Umbraco.Cms.SqlCe" Version="9.0.0-beta003" />
7+
<PackageReference Include="Umbraco.Cms" Version="9.0.0" />
8+
<PackageReference Include="Umbraco.Cms.SqlCe" Version="9.0.0" />
99
</ItemGroup>
1010

1111

src/Our.Umbraco.GraphQL/Adapters/Examine/Types/SearchResultGraphType.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Examine;
22
using GraphQL.Types;
33
using Our.Umbraco.GraphQL.Adapters.PublishedContent.Types;
4+
using System;
45
using System.Collections.Generic;
56
using Umbraco.Cms.Core.PublishedCache;
67

@@ -25,7 +26,15 @@ public SearchResultGraphType(IPublishedSnapshotAccessor snapshotAccessor, string
2526
if (field == "__NodeId")
2627
{
2728
Field<PublishedContentInterfaceGraphType>().Name("_ContentNode").Description("The published content associated with the specified __NodeId value")
28-
.Resolve(ctx => int.TryParse(ctx.Source.Id, out var id) ? snapshotAccessor.PublishedSnapshot.Content.GetById(id) : null);
29+
.Resolve(ctx =>
30+
{
31+
if (!snapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot))
32+
{
33+
throw new InvalidOperationException("Wasn't possible to a get a valid Snapshot");
34+
}
35+
36+
return int.TryParse(ctx.Source.Id, out var id) ? publishedSnapshot.Content.GetById(id) : null;
37+
});
2938
}
3039
}
3140
}

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ private void CreateContentField<T>(ComplexGraphType<T> query, IComplexGraphType
125125
.Bidirectional()
126126
.Resolve(ctx =>
127127
{
128-
var items = fetch(_publishedSnapshotAccessor.PublishedSnapshot.Content,
128+
if (!_publishedSnapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot))
129+
{
130+
throw new InvalidOperationException("Wasn't possible to a get a valid Snapshot");
131+
}
132+
133+
var items = fetch(publishedSnapshot.Content,
129134
ctx.GetArgument<string>("culture")).ToList();
130135

131136
return items.OrderBy(ctx.GetArgument<IEnumerable<OrderBy>>("orderBy"))

src/Our.Umbraco.GraphQL/Composing/FieldMiddlewareCollection.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using Our.Umbraco.GraphQL.Middleware;
34
using Umbraco.Cms.Core.Composing;
@@ -6,7 +7,7 @@ namespace Our.Umbraco.GraphQL.Composing
67
{
78
public class FieldMiddlewareCollection : BuilderCollectionBase<IFieldMiddleware>
89
{
9-
public FieldMiddlewareCollection(IEnumerable<IFieldMiddleware> items)
10+
public FieldMiddlewareCollection(Func<IEnumerable<IFieldMiddleware>> items)
1011
: base(items)
1112
{
1213
}

src/Our.Umbraco.GraphQL/Composing/GraphVisitorCollection.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using Our.Umbraco.GraphQL.Adapters.Visitors;
34
using Umbraco.Cms.Core.Composing;
@@ -6,7 +7,7 @@ namespace Our.Umbraco.GraphQL.Composing
67
{
78
public class GraphVisitorCollection : BuilderCollectionBase<IGraphVisitor>
89
{
9-
public GraphVisitorCollection(IEnumerable<IGraphVisitor> items)
10+
public GraphVisitorCollection(Func<IEnumerable<IGraphVisitor>> items)
1011
: base(items)
1112
{
1213
}

src/Our.Umbraco.GraphQL/Our.Umbraco.GraphQL.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@
3939
<ItemGroup>
4040
<PackageReference Include="GraphQL.Server.Transports.AspNetCore.SystemTextJson" Version="5.0.2" />
4141
<PackageReference Include="GraphQL.Server.Ui.Playground" Version="5.0.2" />
42-
<PackageReference Include="Umbraco.Cms.Web.Common" Version="9.0.0-beta003" />
42+
<PackageReference Include="Umbraco.Cms.Web.Common" Version="9.0.0" />
4343
</ItemGroup>
4444
</Project>

src/Our.Umbraco.GraphQL/Types/PublishedContent/PublishedContentAtRootQuery.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ public PublishedContentAtRootQuery(IPublishedSnapshotAccessor snapshotAccessor)
1717
_snapshotAccessor = snapshotAccessor ?? throw new ArgumentNullException(nameof(snapshotAccessor));
1818
}
1919

20-
protected IPublishedSnapshot Snapshot => _snapshotAccessor.PublishedSnapshot;
21-
protected IPublishedContentCache Content => Snapshot.Content;
22-
20+
2321
[NonNull, NonNullItem]
2422
public Connection<IPublishedContent> All(string culture = null, int? first = null, string after = null,
2523
int? last = null, string before = null, IEnumerable<OrderBy> orderBy = null)
2624
{
27-
var rootContent = Content.GetAtRoot(culture).OrderBy(orderBy).ToList();
25+
if (!_snapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot))
26+
{
27+
throw new InvalidOperationException("Wasn't possible to a get a valid Snapshot");
28+
}
29+
30+
var rootContent = publishedSnapshot.Content.GetAtRoot(culture).OrderBy(orderBy).ToList();
2831
return rootContent.ToConnection(x => x.Key, first, after, last, before, rootContent.Count);
2932
}
3033
}

src/Our.Umbraco.GraphQL/Types/PublishedContent/PublishedContentQuery.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ public IPublishedContent ByUrl([Inject] IPublishedSnapshotAccessor snapshotAcces
2222

2323
private static IPublishedContent GetInternal(IPublishedSnapshotAccessor snapshotAccessor, Func<IPublishedContentCache, IPublishedContent> fetch, string culture)
2424
{
25-
var content = fetch(snapshotAccessor.PublishedSnapshot.Content);
25+
if (!snapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot))
26+
{
27+
throw new InvalidOperationException("Wasn't possible to a get a valid Snapshot");
28+
}
29+
30+
var content = fetch(publishedSnapshot.Content);
2631
if (culture == null || content != null && content.IsInvariantOrHasCulture(culture))
2732
return content;
2833

test/Our.Umbraco.GraphQL.Tests/Our.Umbraco.GraphQL.Tests.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
</PropertyGroup>
99
<ItemGroup>
1010
<PackageReference Include="FluentAssertions" Version="5.8.0" />
11-
<PackageReference Include="Microsoft.Owin" Version="4.2.0" />
1211
<PackageReference Include="NSubstitute" Version="4.2.1" />
1312
<PackageReference Include="xunit" Version="2.4.1" />
1413
<PackageReference Include="xunit.runner.console" Version="2.4.1" />

test/Our.Umbraco.GraphQL.Tests/Types/PublishedContent/PublishedContentAtRootQueryTests.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using FluentAssertions;
22
using NSubstitute;
33
using Our.Umbraco.GraphQL.Types.PublishedContent;
4+
using System;
45
using Umbraco.Cms.Core.Models.PublishedContent;
56
using Umbraco.Cms.Core.PublishedCache;
67
using Xunit;
@@ -25,7 +26,11 @@ public void All_WhenCalled_ReturnsRootContent()
2526
};
2627

2728
var snapshotAccessor = Substitute.For<IPublishedSnapshotAccessor>();
28-
snapshotAccessor.PublishedSnapshot.Content.GetAtRoot()
29+
if (!snapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot))
30+
{
31+
throw new InvalidOperationException("Wasn't possible to a get a valid Snapshot");
32+
}
33+
publishedSnapshot.Content.GetAtRoot()
2934
.Returns(items);
3035
var query = CreateSUT(snapshotAccessor);
3136

test/Our.Umbraco.GraphQL.Tests/Types/PublishedContent/PublishedContentQueryTests.cs

+20-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ public void ById_WhenContentExists_ReturnsPublishedContent()
3232
content.Key.Returns(new Guid("3B1E9E9C-A89E-4FE0-902D-3466D8678E47"));
3333

3434
var snapshotAccessor = Substitute.For<IPublishedSnapshotAccessor>();
35-
snapshotAccessor.PublishedSnapshot.Content.GetById(Arg.Is(content.Key))
35+
if (!snapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot))
36+
{
37+
throw new InvalidOperationException("Wasn't possible to a get a valid Snapshot");
38+
}
39+
publishedSnapshot.Content.GetById(Arg.Is(content.Key))
3640
.Returns(content);
3741

3842
var actual = query.ById(snapshotAccessor, new Id(content.Key.ToString()));
@@ -47,7 +51,11 @@ public void ById_WhenContentDoesNotExists_ReturnsNull()
4751
var id = new Guid("3B1E9E9C-A89E-4FE0-902D-3466D8678E47");
4852

4953
var snapshotAccessor = Substitute.For<IPublishedSnapshotAccessor>();
50-
snapshotAccessor.PublishedSnapshot.Content.GetById(Arg.Is(id))
54+
if (!snapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot))
55+
{
56+
throw new InvalidOperationException("Wasn't possible to a get a valid Snapshot");
57+
}
58+
publishedSnapshot.Content.GetById(Arg.Is(id))
5159
.Returns((IPublishedContent)null);
5260

5361
var actual = query.ById(snapshotAccessor, new Id(id.ToString()));
@@ -74,7 +82,11 @@ public void ByUrl_WhenContentExists_ReturnsPublishedContent()
7482
content.Key.Returns(new Guid("3B1E9E9C-A89E-4FE0-902D-3466D8678E47"));
7583

7684
var snapshotAccessor = Substitute.For<IPublishedSnapshotAccessor>();
77-
snapshotAccessor.PublishedSnapshot.Content.GetByRoute("/")
85+
if (!snapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot))
86+
{
87+
throw new InvalidOperationException("Wasn't possible to a get a valid Snapshot");
88+
}
89+
publishedSnapshot.Content.GetByRoute("/")
7890
.Returns(content);
7991

8092
var actual = query.ByUrl(snapshotAccessor, "/");
@@ -88,7 +100,11 @@ public void ByUrl_WhenContentDoesNotExists_ReturnsNull()
88100
var query = CreateSUT();
89101

90102
var snapshotAccessor = Substitute.For<IPublishedSnapshotAccessor>();
91-
snapshotAccessor.PublishedSnapshot.Content.GetByRoute("/")
103+
if (!snapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot))
104+
{
105+
throw new InvalidOperationException("Wasn't possible to a get a valid Snapshot");
106+
}
107+
publishedSnapshot.Content.GetByRoute("/")
92108
.Returns((IPublishedContent)null);
93109

94110
var actual = query.ByUrl(snapshotAccessor, "/");

0 commit comments

Comments
 (0)