-
Notifications
You must be signed in to change notification settings - Fork 52
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
Non integer id broken with mutation #62
Comments
Thanks for this issue, Marius, The problem here is, that Vuex-ORM only supports integer IDs as far as I know and thus this plugin expects integer IDs too. @kiaking Can you say something about the state of non-integer IDs for Vuex-ORM records? I think there was some issue when not using |
@phortx Vuex ORM don't have any limitation on the value of ID (value of primary key). it can be string or number. or even null or boolean as well (I don't think you should though). So I think there's no problem storing the id value as string. In fact, Vuex ORM will convert the primary key value to string if it's number, for the key of the state. For example; // If you save this data.
const data = {
id: 1 // <- Number
}
// It becomes like this inside the state.
{
'1': { // <- Key is the ID value and it's always string.
id: 1
}
} If the ID value is string, it becomes like this. const data = {
id: 'string-id-001'
}
// Inside state.
{
'string-id-001': {
id: 'string-id-001'
}
} You are correct about |
Ok, that sounds good. Thanks for the reply! I will try to move to string based IDs soon, however PRs are welcome :) |
@kiaking I was successfully using string based ids until I had to set up a pivot table. It sets up fine with ints but not strings. Will be digging into it more this weekend. Hopefully I'm wrong. I want ID overwrites for some of them. It's a series of defined roles; enumeration. |
I've setup a PR to make this pluggin support string based IDs. And all tests pass except the ones for hasManyThrough (pivot table) relations. I think there might by a bug in the core :) |
Should be working with the next release. |
If a mutation returns a non integer id (like a relay node), a new record with id NaN is created.
I found this while debugging:
plugin-graphql/src/actions/action.ts
Line 44 in 0730a86
Something like this might be better:
The text was updated successfully, but these errors were encountered: