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

persist ID as string shows NaN

Open shidcordero opened this issue 4 years ago • 2 comments

Describe the bug

when id type is string, it shows NaN after persist

Steps to reproduce the bug

i have this model

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

export default class Make extends ORMModel {
  static entity = 'makes'
  static eagerLoad = ['models']

  static fields() {
    return {
      id: this.string(),
      name: this.string(null).nullable(),
      active: this.boolean(true),
      models: this.hasMany(Model, 'makeId')
    }
  }
}

I use fireorm as database and everytime the model transform and inserted in vuex-orm store. it shows NaN. see console.log output:

image

Expected behaviour

Should allow id as string type and save correct id value.

Versions

  • Vuex ORM: 0.36.3
  • I am using Nuxt: 2.14.12

shidcordero avatar Jan 27 '21 02:01 shidcordero

I think it because of toPrimaryKey method which used on id from server response.

See my issue: https://github.com/vuex-orm/plugin-graphql/issues/173

Dotrox avatar Feb 02 '21 02:02 Dotrox

so I ended up creating a path file for plugin-graphql and remove the Guid formatting and leave it just a string.

shidcordero avatar Feb 03 '21 06:02 shidcordero