Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unable to create new entity and leave ID generation up to the DB, when using UNIQUEIDENTIFIER DEFAULT NEWID() #2129

Open
pingu2k4 opened this issue Mar 22, 2024 · 0 comments
Labels
bug Something isn't working triage issues to be triaged

Comments

@pingu2k4
Copy link

What happened?

Hey.
I have a table in a minimal repro, which you can create with the following:

CREATE TABLE [dbo].[NewTable](
	[id] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(),
	[test] INT NOT NULL,
 CONSTRAINT [PK_NewTable] PRIMARY KEY ([id])
)

Go ahead and dab add this entity into your config.

The schema that DAB will be using has a CreateNewTableInput where the id field is nullable, which is accurate as the DB can handle generating the id for us.

However, if we run the mutation by passing the item in as a variable, then it fails with an internal server error.

Example mutation:

mutation CreateNewTable($item: CreateNewTableInput!) {
    createNewTable(item: $item) {
        id
    }
}

variables:

{
    "item": {
        "test": 9001
    }
}

The response I get back from DAB is the following:

{
    "errors": [
        {
            "message": "UUID cannot parse the given literal of type `StringValueNode`.",
            "path": [
                "item",
                "id"
            ],
            "extensions": {
                "field": "CreateNewTableInput.id",
                "fieldType": "UUID"
            }
        }
    ]
}

Version

0.9.7+e560142426d1c080b9fd7b7fabff51a276f6bf61

What database are you using?

Azure SQL

What hosting model are you using?

Local (including CLI), 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 https://localhost:5001/graphql application/json 193
dbug: Azure.DataApiBuilder.Core.AuthenticationHelpers.ClientRoleHeaderAuthenticationMiddleware[0]
      792550a5-ee74-4788-9e50-27e8c72f0c3a Request authentication state: Anonymous.
dbug: Azure.DataApiBuilder.Core.AuthenticationHelpers.ClientRoleHeaderAuthenticationMiddleware[0]
      792550a5-ee74-4788-9e50-27e8c72f0c3a The request will be executed in the context of the role: Anonymous
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'Hot Chocolate GraphQL Pipeline'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'Hot Chocolate GraphQL Pipeline'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 POST https://localhost:5001/graphql application/json 193 - 500 - application/json;+charset=utf-8 19.2080ms


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
@pingu2k4 pingu2k4 added bug Something isn't working triage issues to be triaged labels Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage issues to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant