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

graphql inserts works, but insert failed with integer field #85

Closed
archtaurus opened this issue Mar 7, 2021 · 6 comments · Fixed by #89
Closed

graphql inserts works, but insert failed with integer field #85

archtaurus opened this issue Mar 7, 2021 · 6 comments · Fixed by #89

Comments

@archtaurus
Copy link

Bug report

Describe the bug

graphql inserts works, but insert failed with integer field.

Steps to reproduce the behavior

  1. yarn create tensei-app cats
  2. cd cats
  3. edit index.js as
const { auth } = require('@tensei/auth')
const { graphql } = require('@tensei/graphql')
const { tensei, resource, text, integer } = require('@tensei/core')
tensei()
    .root(__dirname)
    .resources([resource('Cat').fields([text('Name'), integer('Age')])])
    .plugins([auth().plugin(), graphql().plugin()])
    .start()
    .catch(console.error)
  1. yarn dev
  2. goto http://localhost:8810/graphql
  3. mutation { insert_cats( objects:[{ name: "Tom", age: 3 }] ) { id } } works
  4. mutation { insert_cat( object:{ name: "Tom", age: 3 } ) { id } } failed with
{
  "errors": [
    {
      "message": "Validation failed.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "insert_cat"
      ],
      "extensions": {
        "errors": [
          {
            "message": "string validation failed on age",
            "validation": "string",
            "field": "age"
          }
        ],
        "code": "BAD_USER_INPUT",
        "exception": {
          "errors": [
            {
              "message": "string validation failed on age",
              "validation": "string",
              "field": "age"
            }
          ],
          "stacktrace": [
            "UserInputError: Validation failed.",
            "    at Object.context.userInputError (/home/username/test/bug/node_modules/@tensei/graphql/build/index.js:445:67)",
            "    at /home/username/test/bug/node_modules/@tensei/graphql/build/Resolvers.js:59:31",
            "    at processTicksAndRejections (internal/process/task_queues.js:93:5)",
            "    at async /home/username/test/bug/node_modules/@tensei/graphql/build/index.js:446:32"
          ]
        }
      }
    }
  ],
  "data": null
}

Expected behavior

insert one cat

Screenshots

In Graphql Playground, TYPE DETAILS for insert_cat(...):cat!

Screenshot_2021-03-07 Playground - http localhost 8810 graphql(1)

It reads age: String. Is this a mistake?

Code snippets

N/A

System

  • Node.js version: v14.15.4
  • NPM version: 7.6.0
  • Tensei version: 0.7.20
  • Database: sqlite
  • Operating system: Arch Linux

Additional context

N/A

@bahdcoder
Copy link
Member

Thanks for sharing. Your issues are very well explained. I might already have an idea why this is happening. Will push a fix and notify you soon.Thanks !

@archtaurus
Copy link
Author

Thanks! And why it's called tensei?

@bahdcoder
Copy link
Member

bahdcoder commented Mar 7, 2021

It's called Tensei because I love anime, and this scene from Naruto Shippuden has lived in my heart ever since I watched it 😅

bahdcoder added a commit that referenced this issue Mar 8, 2021
add validation to insert_many mutation, fix correct validation to integer field

fix #85
bahdcoder added a commit that referenced this issue Mar 8, 2021
add validation to insert_many mutation, fix correct validation to integer field

fix #85
bahdcoder added a commit that referenced this issue Mar 8, 2021
add validation to insert_many mutation, fix correct validation to integer field

fix #85
bahdcoder added a commit that referenced this issue Mar 8, 2021
add validation to insert_many mutation, fix correct validation to integer field

fix #85
@bahdcoder
Copy link
Member

hey @archtaurus I just published a new patch that fixes this bug. Please confirm when you get a chance if you still experience this. Thanks !

@archtaurus
Copy link
Author

archtaurus commented Mar 8, 2021

I tested new v0.7.23. This bug is fixed and gone! 👋
PS, when will be the v1.0? 🙏 I wish it will replace strapi for my personal site.

@bahdcoder
Copy link
Member

@archtaurus v1.0 will be our very first stable release. Once we have deployments to Vercel, Netlify, tons of bug fixes, full typescript support and tons and tons of tutorials then v1 will be ready.

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.

2 participants