Skip to content

[Bug]: Failed to convert parameter value from a String to a Guid. #1598

@yorek

Description

@yorek

What happened?

Using GraphQL, columns using GUIDs cannot be filtered, for example:

query {
  todos(filter: { category_id: {eq: "0B216E5C-C302-4555-9F3D-F2E856A6D79B"}}) {
    items {
      id
      title
      owner_id
    }
  }
}

generates and error. The table is defined as:

CREATE TABLE [dbo].[todos](
	[id] [uniqueidentifier] NOT NULL,
	[category_id] [uniqueidentifier] NULL,
	[title] [nvarchar](1000) NOT NULL,
	[completed] [bit] NOT NULL,
	[custom] [nvarchar](max) NULL,
	[owner_id] [varchar](128) NOT NULL,
	[created_on] [datetime2](7) NOT NULL,
	[position] [int] NULL,
	[created_on_date]  AS (CONVERT([date],[created_on]))
)

and the entity configuration, in the dab-config, is:

    "Todos": {
      "source": "dbo.todos",
      "permissions": [
        {
          "role": "anonymous",
          "actions": [
            "*"
          ]
        }
      ],
      "rest": {
        "path": "/todos"
      }

with REST everything works fine, and I can filter the rows:

https://localhost:5001/api/todos?$filter=category_id%20eq%2000000000-0000-0000-0000-000000000000

Version

Microsoft.DataApiBuilder 0.7.6+61de247acf65280d93783072226f695536591ffb

What database are you using?

Azure SQL

What hosting model are you using?

Local (including CLI)

Which API approach are you accessing DAB through?

GraphQL

Relevant log output

info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'Hot Chocolate GraphQL Pipeline'
dbug: Azure.DataApiBuilder.Service.Resolvers.IQueryExecutor[0]
      e46c92e2-17f4-4ed7-998f-6849745d18cc: Executing query:
SELECT TOP 100 [table0].[id] AS [id], [table0].[title] AS [title], [table0].[owner_id] AS [owner_id] FROM [dbo].[todos] AS [table0] WHERE [table0].[category_id] = @param1 ORDER BY [table0].[id] ASC FOR JSON PATH, INCLUDE_NULL_VALUES
fail: Azure.DataApiBuilder.Service.Startup[0]
      Failed to convert parameter value from a String to a Guid.
fail: Azure.DataApiBuilder.Service.Startup[0]
         at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__208_0(Task`1 result)
         at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
         at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
         at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
      --- End of stack trace from previous location ---
         at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
      --- End of stack trace from previous location ---
         at Azure.DataApiBuilder.Service.Resolvers.QueryExecutor`1.ExecuteQueryAgainstDbAsync[TResult](TConnection conn, String sqltext, IDictionary`2 parameters, Func`3 dataReaderHandler, HttpContext httpContext, List`1 args)
         at Azure.DataApiBuilder.Service.Resolvers.QueryExecutor`1.<>c__DisplayClass19_0`1.<<ExecuteQueryAsync>b__0>d.MoveNext()
      --- End of stack trace from previous location ---
         at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Func`5 onRetryAsync, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider, Boolean continueOnCapturedContext)
         at Polly.AsyncPolicy.ExecuteAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, Boolean continueOnCapturedContext)
         at Azure.DataApiBuilder.Service.Resolvers.QueryExecutor`1.ExecuteQueryAsync[TResult](String sqltext, IDictionary`2 parameters, Func`3 dataReaderHandler, HttpContext httpContext, List`1 args)
         at Azure.DataApiBuilder.Service.Resolvers.SqlQueryEngine.ExecuteAsync(SqlQueryStructure structure)
         at Azure.DataApiBuilder.Service.Resolvers.SqlQueryEngine.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)

Code of Conduct

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggraphqltriageissues to be triaged

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions