VirtoCommerce / vc-frontend

Virto Commerce Frontend - B2B SPA is a fresh look on the field of eCommerce solutions. This is a place where common B2B and B2C scenarios are combined with the most bleeding edge technologies to deliver blazing fast and fully functional solution. It implements common business use-cases needed for a vast majority of projects we build.
https://virtostart-demo-store.govirto.com/
Other
37 stars 31 forks source link

query getMyCart return GraphQL.Execution.UnhandledError: Error trying to resolve field 'cart' System.ArgumentNullException: Value cannot be null #65

Closed six006 closed 2 years ago

six006 commented 2 years ago

http://localhost:2083/xapi/graphql

{"operationName":"getMyCart","variables":{"storeId":"B2B-store","userId":"dcdb108a-d731-46b8-ad58-69d976006c31","currencyCode":"USD","cultureName":"en-US"},"query":"query getMyCart($storeId: String!, $userId: String!, $currencyCode: String!, $cultureName: String) {\n  cart(\n    storeId: $storeId\n    userId: $userId\n    currencyCode: $currencyCode\n    cultureName: $cultureName\n  ) {\n    id\n    name\n    comment\n    purchaseOrderNumber\n    coupons {\n      code\n    }\n    itemsCount\n    itemsQuantity\n    shipments {\n      id\n      shipmentMethodCode\n      shipmentMethodOption\n      deliveryAddress {\n        ...cartAddressFields\n      }\n      price {\n        ...moneyFields\n      }\n    }\n    discounts {\n      promotionId\n      description\n      amount\n      coupon\n    }\n    payments {\n      id\n      paymentGatewayCode\n      billingAddress {\n        ...cartAddressFields\n      }\n    }\n    addresses {\n      ...cartAddressFields\n    }\n    items {\n      ...lineItemFields\n    }\n    currency {\n      ...currencyFields\n    }\n    total {\n      ...moneyFields\n    }\n    discountTotal {\n      ...moneyFields\n    }\n    subTotal {\n      ...moneyFields\n    }\n    shippingTotal {\n      ...moneyFields\n    }\n    shippingPrice {\n      ...moneyFields\n    }\n    taxTotal {\n      ...moneyFields\n    }\n    extendedPriceTotal {\n      ...moneyFields\n    }\n    extendedPriceTotalWithTax {\n      ...moneyFields\n    }\n    validationErrors(ruleSet: \"items\") {\n      errorCode\n      errorMessage\n      errorParameters {\n        key\n        value\n      }\n      objectId\n    }\n    availablePaymentMethods {\n      code\n      logoUrl\n      price {\n        ...moneyFields\n      }\n    }\n    availableShippingMethods {\n      id\n      code\n      logoUrl\n      optionName\n      optionDescription\n      price {\n        ...moneyFields\n      }\n    }\n    gifts {\n      id\n      imageUrl\n      name\n      lineItemId\n    }\n    availableGifts {\n      id\n      imageUrl\n      name\n      lineItemId\n    }\n  }\n}\n\nfragment cartAddressFields on CartAddressType {\n  id\n  name\n  organization\n  firstName\n  lastName\n  line1\n  line2\n  city\n  countryCode\n  countryName\n  regionId\n  regionName\n  postalCode\n  zip\n  phone\n  email\n  addressType\n}\n\nfragment lineItemFields on LineItemType {\n  id\n  imageUrl\n  inStockQuantity\n  isGift\n  isReadOnly\n  isReccuring\n  isValid\n  name\n  productId\n  product {\n    brandName\n    slug\n    masterVariation {\n      id\n    }\n    minQuantity\n    maxQuantity\n    variations {\n      id\n      minQuantity\n      maxQuantity\n    }\n  }\n  quantity\n  sku\n  thumbnailImageUrl\n  validationErrors {\n    errorCode\n    errorMessage\n    errorParameters {\n      key\n      value\n    }\n  }\n  extendedPrice {\n    ...moneyFields\n  }\n  listPrice {\n    ...moneyFields\n  }\n  taxTotal {\n    ...moneyFields\n  }\n}\n\nfragment moneyFields on MoneyType {\n  amount\n  decimalDigits\n  formattedAmount\n  formattedAmountWithoutCurrency\n  formattedAmountWithoutPoint\n  formattedAmountWithoutPointAndCurrency\n  currency {\n    ...currencyFields\n  }\n}\n\nfragment currencyFields on CurrencyType {\n  code\n  customFormatting\n  exchangeRate\n  symbol\n}\n"}

response

{"errors":[{"message":"GraphQL.Execution.UnhandledError: Error trying to resolve field 'cart'.\r\n ---> System.ArgumentNullException: Value cannot be null. (Parameter 'principal')\r\n   at System.Security.Claims.PrincipalExtensions.FindFirstValue(ClaimsPrincipal principal, String claimType)\r\n   at VirtoCommerce.Platform.Security.Authorization.PermissionAuthorizationHandlerBase`1.HandleRequirementAsync(AuthorizationHandlerContext context, TRequirement requirement) in E:\\VirtoCommerce\\5.Source\\vc-platform-3.204.0\\src\\VirtoCommerce.Platform.Security\\Authorization\\PermissionAuthorizationHandlerBase.cs:line 15\r\n   at Microsoft.AspNetCore.Authorization.AuthorizationHandler`1.HandleAsync(AuthorizationHandlerContext context)\r\n   at Microsoft.AspNetCore.Authorization.DefaultAuthorizationService.AuthorizeAsync(ClaimsPrincipal user, Object resource, IEnumerable`1 requirements)\r\n   at VirtoCommerce.XPurchase.Schemas.PurchaseSchema.CheckAccessToCartAsync(IResolveFieldContext context, ShoppingCart cart) in /home/runner/work/vc-module-experience-api/vc-module-experience-api/src/XPurchase/VirtoCommerce.XPurchase/Schemas/PurchaseSchema.cs:line 1230\r\n   at VirtoCommerce.XPurchase.Schemas.PurchaseSchema.<Build>b__6_37(IResolveFieldContext context) in /home/runner/work/vc-module-experience-api/vc-module-experience-api/src/XPurchase/VirtoCommerce.XPurchase/Schemas/PurchaseSchema.cs:line 85\r\n   at GraphQL.Execution.ExecutionStrategy.ExecuteNodeAsync(ExecutionContext context, ExecutionNode node) in /_/src/GraphQL/Execution/ExecutionStrategy.cs:line 429\r\n   --- End of inner exception stack trace ---","locations":[{"line":2,"column":3}],"path":["cart"],"extensions":{"code":"ARGUMENT_NULL","codes":["ARGUMENT_NULL"]}}],"data":{"cart":null}}

image

mvktsk commented 2 years ago

Task https://virtocommerce.atlassian.net/browse/VP-7960 has been created

Flanker72 commented 2 years ago

@six006 please, have a look on this comment - it seems to be the same error