Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCC-245: Update OC preview version and fix breaking changes #142

Merged
merged 29 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a8205ff
Update OC preview version.
sarahelsaig May 28, 2024
3f6b261
Fix breaking changes.
sarahelsaig May 28, 2024
1b6868e
grammar
sarahelsaig May 28, 2024
4c5fcac
Bug fix.
sarahelsaig May 28, 2024
3092386
Update OC preview version.
sarahelsaig May 30, 2024
308f5e2
Update OC preview version.
sarahelsaig Jun 5, 2024
836571f
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jun 14, 2024
f2f8c4b
Fix build error.
sarahelsaig Jun 17, 2024
cccccd8
Update OC version.
sarahelsaig Jun 18, 2024
c8776f2
Update OC version.
sarahelsaig Jun 19, 2024
86968be
Update OC preview version.
sarahelsaig Jun 21, 2024
4057643
Update OC preview version.
sarahelsaig Jul 11, 2024
201eefd
Fix package consolidation.
sarahelsaig Jul 11, 2024
5f8c6c2
Update HL version.
sarahelsaig Jul 13, 2024
d203dfa
Update HL nuget version.
sarahelsaig Jul 16, 2024
b31788f
Fix outdated suppression.
sarahelsaig Jul 24, 2024
bbc44dc
Remove outdated comment.
sarahelsaig Jul 24, 2024
b2c2510
Update OC preview versions.
sarahelsaig Jul 24, 2024
9282ffe
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jul 24, 2024
9986850
Fixing ambiguous HTTP methods as warned by Swagger
Piedone Jul 26, 2024
f3a9d45
Fix duplicate PackageReference.
sarahelsaig Jul 26, 2024
701a0b3
Update OC preview version.
sarahelsaig Jul 26, 2024
258e119
Fix build warnings.
sarahelsaig Jul 26, 2024
09e2121
Add LombiqPreview to the NuGet.config.
sarahelsaig Jul 26, 2024
52479dc
Fix GraphQL filter PersonAgeGraphQLFilter.
sarahelsaig Jul 26, 2024
71d8d3b
Update HL preview version.
sarahelsaig Jul 26, 2024
067fa3c
Update HL preview.
sarahelsaig Jul 27, 2024
83312a6
Update HL nuget version.
sarahelsaig Jul 27, 2024
bc78c58
Update HL.
sarahelsaig Jul 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Lombiq.TrainingDemo.Tests/Services/TestedServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ public void NonExistingContentItemsShouldThrow()

mocker
.GetMock<IContentManager>()
.Verify(contentManager => contentManager.GetAsync(It.Is<string>(id => id == TestContentId)));
.Verify(contentManager => contentManager.GetAsync(It.Is<string>(id => id == TestContentId), It.IsAny<VersionOptions>()));
}

[Fact]
public async Task ContentItemsAreRetrieved()
{
// In this test we'll mock IContentManager so it actually returns something we can then verify.
// In this test we'll mock IContentManager, so it actually returns something we can then verify.

var service = CreateTestedService(out var mocker);

// Setting up an IContentManager mock that'll return a basic ContentItem placeholder.
mocker
.GetMock<IContentManager>()
.Setup(contentManager => contentManager.GetAsync(It.IsAny<string>()))
.ReturnsAsync<string, IContentManager, ContentItem>(id => new ContentItem { ContentItemId = id });
.Setup(contentManager => contentManager.GetAsync(It.IsAny<string>(), It.IsAny<VersionOptions>()))
.ReturnsAsync<string, VersionOptions, IContentManager, ContentItem>((id, _) => new ContentItem { ContentItemId = id });

var contentItem = await service.GetContentItemOrThrowAsync(TestContentId);

Expand All @@ -71,7 +71,7 @@ private static TestedService CreateTestedService(out AutoMocker mocker)
// We're using a library called AutoMocker here. It extends the Moq mocking library with the ability to
// automatically substitute injected dependencies with a mocked instance. It's a bit like a special dependency
// injection container. This way, your tested classes will get all their dependencies injected even if you don't
// explicitly register a mock or stub for the.
// explicitly register a mock or stub.

mocker = new AutoMocker();
return mocker.CreateInstance<TestedService>();
Expand Down
7 changes: 3 additions & 4 deletions Lombiq.TrainingDemo.Web/Lombiq.TrainingDemo.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Logging.NLog" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.Application.Cms.Targets" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.Application.Cms.Targets" Version="1.8.3" />
<PackageReference Include="OrchardCore.Logging.NLog" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.Application.Cms.Targets" Version="2.0.0-preview-18282" />
<!-- This reference is not strictly needed here but included so if the web and the module projects' Orchard Core
versions go out of sync, the CI build's package consolidation validation will fail. -->
<PackageReference Include="OrchardCore.ContentManagement" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.ContentManagement" Version="2.0.0-preview-18282" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Lombiq.TrainingDemo.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
.UseStaticFiles()
.UseOrchardCore();

app.Run();
await app.RunAsync();
7 changes: 1 addition & 6 deletions Lombiq.TrainingDemo/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ namespace Lombiq.TrainingDemo.Controllers;
// endpoints should most of the time use the "Api" authentication scheme: This is not the same that standard users are
// authenticated with (via cookies).
[Authorize(AuthenticationSchemes = "Api"), IgnoreAntiforgeryToken, AllowAnonymous]
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Major Code Smell",
"S6961:API Controllers should derive from ControllerBase instead of Controller",
Justification = "Can't be changed due to line 62. Will be applicable after an Orchard upgrade due to " +
"https://github.com/OrchardCMS/OrchardCore/issues/16186 being fixed.")]
public class ApiController : Controller
public class ApiController : ControllerBase
{
private readonly IAuthorizationService _authorizationService;
private readonly IContentManager _contentManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class CrossTenantServicesController : Controller
// A simple route for convenience. You can access this from under /CrossTenantServices?contentItemId=ID. Here ID
// needs to be a content item ID that you can get e.g. from the URL when you open an item to edit from the admin (it
// looks something like "4da2sme18cc2k2r5d4w23d4cwj" which is NOT made by a cat walking across the keyboard!).
[Route("CrossTenantServices")]
[HttpGet, Route("CrossTenantServices")]
public async Task<string> Index(string contentItemId)
{
// If ModelState is not in a valid state we should abort the action and return null.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ActionResult Index()
}

// Let's see some custom routing here. This attribute will override the default route and use this one.
[Route("TrainingDemo/NotifyMe")]
[HttpGet, Route("TrainingDemo/NotifyMe")]
public async Task<IActionResult> NotifyMe()
{
// ILogger is an ASP.NET Core service that will write something into the specific log files. In Orchard Core
Expand Down
14 changes: 7 additions & 7 deletions Lombiq.TrainingDemo/GraphQL/Services/ContentItemTypeBuilder.cs
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ContentItemTypeBuilder : IContentTypeBuilder

// Here you can add arguments to every Content Type (top level) field.
public void Build(
ISchema schema,
FieldType contentQuery,
ContentTypeDefinition contentTypeDefinition,
ContentItemType contentItemType)
Expand All @@ -26,11 +27,7 @@ public void Build(

// The resolved type can be anything that can be represented with JSON and has a known graph type, but we stick
// with numbers for simplicity's sake. This one filters for equation.
contentQuery.Arguments.Add(new QueryArgument<IntGraphType>
{
Name = AgeFilterName,
ResolvedType = new IntGraphType(),
});
AddFilter(contentQuery, suffix: string.Empty);

// You can't use special characters in the argument names so by GraphQL convention these two letter suffixes
// that represent the relational operators. Except equation which customarily gets no suffix.
Expand All @@ -43,12 +40,15 @@ public void Build(
AddFilter(contentQuery, "_ne");
}

private static void AddFilter(FieldType contentQuery, string suffix) =>
contentQuery.Arguments.Add(new QueryArgument<IntGraphType>
private static void AddFilter(FieldType contentQuery, string suffix)
{
contentQuery.Arguments ??= [];
contentQuery.Arguments!.Add(new QueryArgument<IntGraphType>
{
Name = AgeFilterName + suffix,
ResolvedType = new IntGraphType(),
});
}
}

// NEXT STATION: Services/PersonAgeGraphQLFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Task<IEnumerable<ContentItem>> PostQueryAsync(
IResolveFieldContext context)
{
var (name, value) = context.Arguments.FirstOrDefault(
argument => argument.Key.StartsWith(AgeFilterName, StringComparison.Ordinal));
argument => argument.Value.Value is int && argument.Key.StartsWithOrdinal(AgeFilterName));

if (name != null && value.Value is int age)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,4 @@ public PersonPartObjectGraphType()
}
}

// Warning: There seems to be a bug when your query includes the built-in "biography" field before the "person" field.
// If you do it the other way around it works though. You can track the issue here:
// https://github.com/OrchardCMS/OrchardCore/issues/10181

// NEXT STATION: Services/PersonPartWhereInputObjectGraphType.cs
30 changes: 15 additions & 15 deletions Lombiq.TrainingDemo/Lombiq.TrainingDemo.csproj
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="OrchardCore.Users.Abstractions" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.Workflows.Abstractions" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.BackgroundTasks" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.ContentFields" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.ContentManagement" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.ContentTypes.Abstractions" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.Data.Abstractions" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.DynamicCache" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.FileStorage.FileSystem" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.Indexing.Abstractions" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.Media.Abstractions" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.Module.Targets" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.Users.Abstractions" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.Workflows.Abstractions" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.BackgroundTasks" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.ContentFields" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.ContentManagement" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.ContentTypes.Abstractions" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.Data.Abstractions" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.DynamicCache" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.FileStorage.FileSystem" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.Indexing.Abstractions" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.Media.Abstractions" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.Module.Targets" Version="2.0.0-preview-18282" />
<!-- Note that you need to add a reference to OrchardCore.ResourceManagement for the basic tag helpers like <style>
and <script> to properly work when the app is built for production (and thus Razor Runtime Compilation is turned
off. OrchardCore.DisplayManagement is needed for a variety of things but also for the <shape> tag helper for the
same reason. -->
<PackageReference Include="OrchardCore.ResourceManagement" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.ResourceManagement" Version="2.0.0-preview-18282" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="2.0.0-preview-18282" />
</ItemGroup>

<!-- This module requires Lombiq.HelpfulLibraries.OrchardCore, and it can be included two ways. The PackageReference
Expand All @@ -51,7 +51,7 @@
</ItemGroup>

<ItemGroup Condition="!Exists('..\..\..\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.OrchardCore\Lombiq.HelpfulLibraries.OrchardCore.csproj')">
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="10.0.0" />
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="10.0.1-alpha.2.occ-245" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="OrchardCorePreview" value="https://nuget.cloudsmith.io/orchardcore/preview/v3/index.json" />
<add key="LombiqPreview" value="https://nuget.cloudsmith.io/lombiq/open-source-orchard-core-extensions/v3/index.json" />
</packageSources>
</configuration>