Skip to content

Error when receiving Decimal value without a decimal present  #1629

@jshallBRI

Description

@jshallBRI

What happened?

When trying to update a Numeric or Decimal column in an Azure SQL database using GraphQL, the update will work only if a decimal value is present. If an integer is present, e.g. 123, I receive the following error from the server:

"Unable to cast object of type 'HotChocolate.Language.IntValueNode' to type 'HotChocolate.Language.FloatValueNode'."

If I change that updated value to 123.45, the update will go through successfully. This behavior is consistent across both create and update operations (both with the field being the only one included, or other fields being updated along with it).

Error.txt
Success.txt

The problem that I am running into is that I am using the URQL client to access the DAB GraphQL server, and it does not include the decimal portion of the number if it is zero (123.0 is sent as 123, resulting in the error above).

I would expect DAB to accept an integer value for a Decimal field.

Version

Microsoft.DataApiBuilder 0.7.5+2f938a6dfe4b90c26d9e24352b38280cb6e66f15

What database are you using?

Azure SQL

What hosting model are you using?

Static Web Apps (SWA)

Which API approach are you accessing DAB through?

GraphQL

Relevant log output

info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 POST http://localhost:5000/graphql application/json 436
info: Microsoft.AspNetCore.Cors.Infrastructure.CorsService[4]
      CORS policy execution successful.
dbug: Azure.DataApiBuilder.Service.AuthenticationHelpers.ClientRoleHeaderAuthenticationMiddleware[0]       
      657e14e3-16dd-4c65-bbfb-ed63ad19d1de: Request authentication state: Anonymous.
dbug: Azure.DataApiBuilder.Service.AuthenticationHelpers.ClientRoleHeaderAuthenticationMiddleware[0]       
      657e14e3-16dd-4c65-bbfb-ed63ad19d1de: The request will be executed in the context of Anonymous role  
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'Hot Chocolate GraphQL Pipeline'
fail: Azure.DataApiBuilder.Service.Startup[0]
      Unable to cast object of type 'HotChocolate.Language.IntValueNode' to type 'HotChocolate.Language.FloatValueNode'.
fail: Azure.DataApiBuilder.Service.Startup[0]
         at Azure.DataApiBuilder.Service.Services.ResolverMiddleware.ExtractValueFromIValueNode(IValueNode 
value, IInputField argumentSchema, IVariableValueCollection variables)
         at Azure.DataApiBuilder.Service.Resolvers.BaseSqlQueryStructure.GQLMutArgumentToDictParams(IMiddlewareContext context, String fieldName, IDictionary`2 mutationParameters)
         at Azure.DataApiBuilder.Service.Resolvers.SqlUpdateStructure..ctor(IMiddlewareContext context, String entityName, ISqlMetadataProvider sqlMetadataProvider, IAuthorizationResolver authorizationResolver, GQLFilterParser gQLFilterParser, IDictionary`2 mutationParams, HttpContext httpContext)
         at Azure.DataApiBuilder.Service.Resolvers.SqlMutationEngine.PerformMutationOperation(String entityName, Operation operationType, IDictionary`2 parameters, IMiddlewareContext context)
         at Azure.DataApiBuilder.Service.Resolvers.SqlMutationEngine.ExecuteAsync(IMiddlewareContext context, IDictionary`2 parameters)
         at Azure.DataApiBuilder.Service.Services.ResolverMiddleware.InvokeAsync(IMiddlewareContext context)
         at HotChocolate.Utilities.MiddlewareCompiler`1.ExpressionHelper.AwaitTaskHelper(Task task)        
         at HotChocolate.Execution.Processing.Tasks.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken)
         at HotChocolate.Execution.Processing.Tasks.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken)
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'Hot Chocolate GraphQL Pipeline'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 POST http://localhost:5000/graphql application/json 436 - 200 - application/json;+charset=utf-8 1614.2282ms

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Labels

bugSomething isn't workingcriCustomer Reported issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions