<p>I wanted to get some more experience working with GraphQL mutations, so I worked on a new feature for my site that enabled a user to “like” a blog article. I ran into a little gotcha that is kind of obvious now that I know the solution but wasn’t obvious at the time.</p>
<p><video src="//assets.trevor-davis.com/uploads/images/content/like-component.mp4" autoplay="" loop="" muted="" controls=""></video></p>
<p>I didn’t think I needed to be fancy and store the “like” in the database and associate with the user, so I decided that tracking whether the user had liked the article in <code>localStorage</code> was enough and then keep track of the total article like count in the database. Seems easy enough right?</p>
<h2>The Problem</h2>
<p>This was my first approach in retrieving whether or not the user had liked the article from <code>localStorage</code>:</p>