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

Error on graphQL mutation #138

Open
codeturn opened this issue Dec 9, 2019 · 1 comment
Open

Error on graphQL mutation #138

codeturn opened this issue Dec 9, 2019 · 1 comment

Comments

@codeturn
Copy link

codeturn commented Dec 9, 2019

Hey. I try to insert new raw in db by graphQl. =/

Model:

import { Model } from '@vuex-orm/core'

export default class Categories extends Model {
  // This is the name used as module name of the Vuex Store.
  static entity = 'categories'

  static fields() {
    return {
      id: this.increment(),
      name: this.attr('')
    }
  }
}

Update method

 async addCat() {
      await Categories.insert({ data: this.newCat });
      const cat = Categories.query().last();
      await cat.$persist();
    },

GraphQl

type Query {
    categories: [Category!]! @all
}

type Category {
    id: ID!
    name: String!
}

input CategoryInput {
    id: ID!
    name: String!
}

type Mutation {
    createCategory(category: CategoryInput): Category! @create
}

So this return 500 server error. I use laravel and lighthouse-php lib.
What I do wrong? And maybe vuex-orm have easy method to save. For example ModelName.saveToServer() as method fetch.. ?

@phortx
Copy link
Collaborator

phortx commented May 2, 2020

It's hard to tell without more information. What is the actual error message on the server?

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

No branches or pull requests

2 participants