mst-gql
mst-gql copied to clipboard
Ability to use non-standard `id` field name
I'm getting an error when fetched data is saved to a root collection:
Error: [mobx-state-tree] A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '3', but expected: 'undefined'
Tracing it with the debugger here's what I've found:

data.idis undefined- at some point the code uses the
idto store the created instance in a map and it fails with the error
I'm not sure if there's some logic that assigns the data.id the actual id for that particular structure is inside data.client_id this is correctly picked up in the scaffolded model
Is there a reason for using set instead of put there ?
Using put would infer the id from the created instance and use the correct key
I've never tried to use mst-gql without using id as my id field name. Looks like we might need to add a way to customize this and/or infer it.
in my case the typeDef object has the identifierAttribute property link With the name of correct id property. Probably it could be used there