mst-gql
mst-gql copied to clipboard
Potentially empty __typename on the client
I think it might be possible to have an empty __typename on the client.
This is an example of the generated __typename field on a model: https://github.com/mobxjs/mst-gql/blob/master/examples/3-twitter-clone/src/app/models/MessageModel.base.ts#L29
The __typename is set when responses come back from the server (when server data is applied in the mergeHelper) but it doesn't seem to be there when the model is created. This could cause problems for apps that don't have a connection to the server and rely on that __typename
I think we might be able to fix the generation code to not make it types.optional and instead just put the typename on there.
Does anyone have opinions or thoughts on this? Am I missing anything related to how mst creates these models?
edit: this was breaking in my own code b/c I relied on __typename to check for the type of an item but I believe I should probably use getType anyway to fix this. Still might be valuable to fix this in mst-gql for anyone who didn't know about getType