When dealing with local data that I want to normalize, one needs to add __typename and id to all elements (if I forget it in one element, this element in not normalized), giving something like:
While ID can be automatically assigned using keyFields, __typename is mandatory. However, it would be great to automatically generate them, for instance using the client-side schema. If parsing the client-side schema adds too much dependency (but I donβt really understand why it is easy to parse queries like IS_LOGGED_IN but not a client-side schema), I can think of other alternatives:
parse the schema at compile time and only bundle the parsed version in json
or just ask the user to provide it in json or via an object (this is the choice made by the (now unmaintained) normalizr library). For instance, this could give:
When dealing with local data that I want to normalize, one needs to add
__typename
andid
to all elements (if I forget it in one element, this element in not normalized), giving something like:While ID can be automatically assigned using
keyFields
,__typename
is mandatory. However, it would be great to automatically generate them, for instance using the client-side schema. If parsing theclient-side schema
adds too much dependency (but I donβt really understand why it is easy to parse queries likeIS_LOGGED_IN
but not a client-side schema), I can think of other alternatives:From this,
writeQuery
could automatically add__typename
, it even seems quite simple to do.Related discussions: https://discord.com/channels/1022972389463687228/1145119756379226192