vuex-orm / plugin-graphql

Vuex ORM persistence plugin to sync the store against a GraphQL API.
https://vuex-orm.github.io/plugin-graphql/
MIT License
227 stars 52 forks source link

persist ID as string shows NaN #172

Open shidcordero opened 3 years ago

shidcordero commented 3 years ago

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

Dotrox commented 3 years ago

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

shidcordero commented 3 years ago

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