Skip to content

Commit

Permalink
feat: add scoped schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ksavosteev committed Nov 25, 2024
1 parent dc05f46 commit 5ede3a5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.10.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.Xapi.Core" Version="3.809.0" />
<PackageReference Include="VirtoCommerce.Xapi.Core" Version="3.814.0-alpha.57-vcst-2241" />
<PackageReference Include="VirtoCommerce.XCatalog.Core" Version="3.817.0" />
<PackageReference Include="VirtoCommerce.CartModule.Core" Version="3.820.0" />
<PackageReference Include="VirtoCommerce.PaymentModule.Core" Version="3.804.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using VirtoCommerce.PricingModule.Core.Model;
using VirtoCommerce.TaxModule.Core.Model;
using VirtoCommerce.Xapi.Core.Extensions;
using VirtoCommerce.Xapi.Core.Infrastructure;
using VirtoCommerce.Xapi.Core.Pipelines;
using VirtoCommerce.XCart.Core;
using VirtoCommerce.XCart.Core.Models;
Expand All @@ -24,6 +25,8 @@ public static IServiceCollection AddXCart(this IServiceCollection services, IGra
{
graphQLBuilder.AddSchema(typeof(CoreAssemblyMarker), typeof(DataAssemblyMarker));

services.AddSingleton<ScopedSchemaFactory<DataAssemblyMarker>>();

services.AddSingleton<IAuthorizationHandler, CanAccessCartAuthorizationHandler>();
services.AddTransient<ICartAggregateRepository, CartAggregateRepository>();
services.AddTransient<ICartValidationContextFactory, CartValidationContextFactory>();
Expand Down
7 changes: 6 additions & 1 deletion src/VirtoCommerce.XCart.Web/Module.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using VirtoCommerce.Platform.Core.Modularity;
using VirtoCommerce.Xapi.Core.Extensions;
using VirtoCommerce.Xapi.Core.Infrastructure;
using VirtoCommerce.Xapi.Core.Models;
using VirtoCommerce.XCart.Data;
using VirtoCommerce.XCart.Data.Extensions;

namespace VirtoCommerce.XCart.Web;
Expand All @@ -20,7 +24,8 @@ public void Initialize(IServiceCollection serviceCollection)

public void PostInitialize(IApplicationBuilder appBuilder)
{
// Nothing to do here
var playgroundOptions = appBuilder.ApplicationServices.GetService<IOptions<GraphQLPlaygroundOptions>>();
appBuilder.UseSchemaGraphQL<ScopedSchemaFactory<DataAssemblyMarker>>(playgroundOptions?.Value?.Enable ?? true, "cart");
}

public void Uninstall()
Expand Down
2 changes: 1 addition & 1 deletion src/VirtoCommerce.XCart.Web/module.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<dependency id="VirtoCommerce.Payment" version="3.804.0" />
<dependency id="VirtoCommerce.Pricing" version="3.809.0" />
<dependency id="VirtoCommerce.Shipping" version="3.802.0" />
<dependency id="VirtoCommerce.Xapi" version="3.809.0" />
<dependency id="VirtoCommerce.Xapi" version="3.814.0" />
<dependency id="VirtoCommerce.XCatalog" version="3.817.0" />
</dependencies>

Expand Down

0 comments on commit 5ede3a5

Please sign in to comment.