Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions src/VirtoCommerce.ExperienceApiModule.Core/Schemas/AddressType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using GraphQL.Types;
using VirtoCommerce.CoreModule.Core.Common;

namespace VirtoCommerce.ExperienceApiModule.Core.Schemas
{
public class AddressType : ObjectGraphType<Address>
{
public AddressType()
{
Field<NonNullGraphType<StringGraphType>>("id", resolve: context => context.Source.Key, description: "Id");
Field(x => x.Key, nullable: false).Description("Id");
Field(x => x.City, nullable: false).Description("City");
Field(x => x.CountryCode, nullable: false).Description("Country code");
Field(x => x.CountryName, nullable: true).Description("Country name");
Field(x => x.Email, nullable: true).Description("Email");
Field(x => x.FirstName, nullable: true).Description("First name");
Field(x => x.MiddleName, nullable: true).Description("Middle name");
Field(x => x.LastName, nullable: true).Description("Last name");
Field(x => x.Line1, nullable: false).Description("Line1");
Field(x => x.Line2, nullable: true).Description("Line2");
Field(x => x.Name, nullable: true).Description("Name");
Field(x => x.Organization, nullable: true).Description("Company name");
Field(x => x.Phone, nullable: true).Description("Phone");
Field(x => x.PostalCode, nullable: false).Description("Postal code");
Field(x => x.RegionId, nullable: true).Description("Region id");
Field(x => x.RegionName, nullable: true).Description("Region name");
Field(x => x.Zip, nullable: false).Description("Zip");
Field(x => x.OuterId, nullable: true).Description("Outer id");
Field<NonNullGraphType<AddressTypeType>>(nameof(Address.AddressType),
"Address type",
resolve: context => context.Source.AddressType);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using GraphQL.Types;

namespace VirtoCommerce.ExperienceApiModule.Core.Schemas
{
public class AddressTypeType: EnumerationGraphType<CoreModule.Core.Common.AddressType>
{
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
using GraphQL.Types;
using VirtoCommerce.ExperienceApiModule.Core.Schemas;
using VirtoCommerce.OrdersModule.Core.Model;

namespace VirtoCommerce.ExperienceApiModule.XOrder.Schemas
{
public class OrderAddressType : ObjectGraphType<Address>
public class OrderAddressType : AddressType
{
public OrderAddressType()
{
Field<StringGraphType>("id", resolve: context => context.Source.Key, description: "Id");
Field(x => x.Key, true).Description("Id");
Field(x => x.City, nullable: true).Description("City");
Field(x => x.CountryCode, nullable: true).Description("Country code");
Field(x => x.CountryName, nullable: true).Description("Country name");
Field(x => x.Email, nullable: true).Description("Email");
Field(x => x.FirstName, nullable: true).Description("First name");
Field(x => x.MiddleName, nullable: true).Description("Middle name");
Field(x => x.LastName, nullable: true).Description("Last name");
Field(x => x.Line1, nullable: true).Description("Line1");
Field(x => x.Line2, nullable: true).Description("Line2");
Field(x => x.Name, nullable: true).Description("Name");
Field(x => x.Organization, nullable: true).Description("Company name");
Field(x => x.Phone, nullable: true).Description("Phone");
Field(x => x.PostalCode, nullable: false).Description("Postal code");
Field(x => x.RegionId, nullable: true).Description("Region id");
Field(x => x.RegionName, nullable: true).Description("Region name");
Field(x => x.Zip, nullable: true).Description("Zip");
Field(x => x.OuterId, nullable: true).Description("Outer id");
Field<IntGraphType>(nameof(Address.AddressType),
"Address type",
resolve: context => (int)context.Source.AddressType);
GetField(nameof(Address.FirstName)).Type = typeof(NonNullGraphType<StringGraphType>);
GetField(nameof(Address.LastName)).Type = typeof(NonNullGraphType<StringGraphType>);
}
}
}
27 changes: 4 additions & 23 deletions src/XPurchase/VirtoCommerce.XPurchase/Schemas/CartAddressType.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
using GraphQL.Types;
using VirtoCommerce.CartModule.Core.Model;
using VirtoCommerce.ExperienceApiModule.Core.Schemas;

namespace VirtoCommerce.XPurchase.Schemas
{
public class CartAddressType : ObjectGraphType<Address>
public class CartAddressType : AddressType
{
public CartAddressType()
{
Field<StringGraphType>("id", resolve: context => context.Source.Key, description: "Id");
Field(x => x.Key, true).Description("Id");
Field(x => x.City, nullable: true).Description("City");
Field(x => x.CountryCode, nullable: true).Description("Country code");
Field(x => x.CountryName, nullable: true).Description("Country name");
Field(x => x.Email, nullable: true).Description("Email");
Field(x => x.FirstName, nullable: true).Description("First name");
Field(x => x.MiddleName, nullable: true).Description("Middle name");
Field(x => x.LastName, nullable: true).Description("Last name");
Field(x => x.Line1, nullable: true).Description("Line1");
Field(x => x.Line2, nullable: true).Description("Line2");
Field(x => x.Name, nullable: true).Description("Name");
Field(x => x.Organization, nullable: true).Description("Company name");
Field(x => x.Phone, nullable: true).Description("Phone");
Field(x => x.PostalCode, nullable: false).Description("Postal code");
Field(x => x.RegionId, nullable: true).Description("Region id");
Field(x => x.RegionName, nullable: true).Description("Region name");
Field(x => x.Zip, nullable: true).Description("Zip");
Field(x => x.OuterId, nullable: true).Description("Outer id");
Field<IntGraphType>(nameof(Address.AddressType),
"Address type",
resolve: context => (int)context.Source.AddressType);
GetField(nameof(Address.FirstName)).Type = typeof(NonNullGraphType<StringGraphType>);
GetField(nameof(Address.LastName)).Type = typeof(NonNullGraphType<StringGraphType>);
}
}
}