plugin-graphql icon indicating copy to clipboard operation
plugin-graphql copied to clipboard

Error on graphQL mutation

Open codeturn opened this issue 4 years ago • 1 comments

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.. ?

codeturn avatar Dec 09 '19 22:12 codeturn

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

phortx avatar May 02 '20 20:05 phortx