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

toPrimaryKey broke ObjectId from MongoDB #173

Open Dotrox opened 3 years ago

Dotrox commented 3 years ago

When I get data from the server all ObjectId cuts because of this method. For example "6018b21ff77a7f08047de270" become "6018" And id: this.string() in vuex-orm models doesn't help!

https://github.com/vuex-orm/plugin-graphql/blob/b6a878d4d8aed66a8634eb846f3894cac4d2e65f/src/support/utils.ts#L140

Why the Hell there is parseInt without checking field type?!

Arsync commented 3 years ago

Same problem, my ids looks like tyr13zqj, without strange prefixes of $uid. We need just to set it as is. Why the Hell we have that conversion of existing data? Plugin must not to change data inside, it just a transport utility.

As workaround, maybe introduce option like 'custom id prefix', which we can set manually while installing the plugin: u- for u-6018b21ff77a7f08047de270 or t for tyr13zqj.

But better to leave it without internal changes. If you have a string, you must show it as string.