-
Notifications
You must be signed in to change notification settings - Fork 3
Description
"path": [
"products",
"items",
"extensions": {
"code": "INVALID_CAST",
"details": "GraphQL.Execution.UnhandledError: Error trying to resolve field 'value'.\r\n ---> System.InvalidCastException: Unable to cast object of type 'System.Double' to type 'System.Decimal'.\r\n at VirtoCommerce.XCatalog.Core.Schemas.PropertyType.ResolveValue(Property source, String languageCode) in /home/runner/work/vc-module-x-catalog/vc-module-x-catalog/src/VirtoCommerce.XCatalog.Core/Schemas/PropertyType.cs:line 124\r\n at GraphQL.Execution.ExecutionStrategy.ExecuteNodeAsync(ExecutionContext context, ExecutionNode node) in //src/GraphQL/Execution/ExecutionStrategy.cs:line 516\r\n --- End of inner exception stack trace ---"
The Problem:
The backend stores property values as object type
For numeric values, they're stored as System.Double
Line 124 tries to directly cast (decimal)propertyValue.Value
C# doesn't allow direct casting from double to decimal - you need to use Convert.ToDecimal()
How to Fix in Backend:
change this:
var decimalValue = (decimal)propertyValue.Value;
to this:
var decimalValue = Convert.ToDecimal(propertyValue.Value);