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

MySQL auto increment field #5350

Closed
4 tasks
ashokkumar88 opened this issue Apr 20, 2023 · 2 comments · Fixed by #5882
Closed
4 tasks

MySQL auto increment field #5350

ashokkumar88 opened this issue Apr 20, 2023 · 2 comments · Fixed by #5882
Assignees

Comments

@ashokkumar88
Copy link

ashokkumar88 commented Apr 20, 2023

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

Make sure to fork this template and run yarn generate in the terminal.

Please make sure Mesh package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review
  • 1. The issue provides a reproduction available on
    Github,
    Stackblitz
    or
    CodeSandbox

Describe the bug

In MySQL handler the auto increment field is generated as Int! in the schema. In Mutation it is throwing error as it is a required field.

Field \"id\" of required type \"Int!\" was not provided."

Expected behavior

The autoincrement field should be of type ID!

Environment:

  • OS: Windows
  • @graphql-mesh/...:
  • NodeJS:

Additional context

@ashokkumar88 ashokkumar88 changed the title ID MySQL auto increment field Apr 20, 2023
@ardatan
Copy link
Owner

ardatan commented Apr 20, 2023

The autoincrement field should be of type ID!

It is correct, MySQL handler creates fields with specific types like Int, Float or String.

In MySQL handler the auto increment field is generated as Int! in the schema. In Mutation it is throwing error as it is a required field.

I didn't understand the issue here. If you share a reproduction, we can help you better.

@ashokkumar88
Copy link
Author

ashokkumar88 commented Apr 21, 2023

Here is an explanation about the issue.

I have a book table with following structure:

id (int) (not null) (primary key) (auto increment)
title (varchar)
category (varchar)

Then I called the following mutation:

mutation MyMutation($book: book_InsertInput = {category:"comics",title:"Book Title"}) {
  insert_book(book: $book) {
    id
  }
}

And it is throwing error that id field is required.

{
  "errors": [
    {
      "message": "Field \"book_InsertInput.id\" of required type \"Int!\" was not provided."
    },
    {
      "message": "Field \"book_InsertInput.id\" of required type \"Int!\" was not provided."
    }
  ]
}

As the id is a primary key and auto increment field, it is auto generated. We cannot pass it in the mutation.

The schema generated for book_InsertInput is also attached.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants