<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Matt Dionis</title>
    <description>The latest articles on Forem by Matt Dionis (@mattdionis).</description>
    <link>https://forem.com/mattdionis</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F218834%2F981393ad-f165-4812-8d54-e4ee902e29f0.jpeg</url>
      <title>Forem: Matt Dionis</title>
      <link>https://forem.com/mattdionis</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mattdionis"/>
    <language>en</language>
    <item>
      <title>What is the most underrated skill of great engineers?</title>
      <dc:creator>Matt Dionis</dc:creator>
      <pubDate>Thu, 29 Aug 2019 20:35:39 +0000</pubDate>
      <link>https://forem.com/mattdionis/what-is-the-most-underrated-skill-of-great-engineers-21a4</link>
      <guid>https://forem.com/mattdionis/what-is-the-most-underrated-skill-of-great-engineers-21a4</guid>
      <description>

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Move Over Redux: Apollo-Client as a State Management Solution (with Hooks 🎉)</title>
      <dc:creator>Matt Dionis</dc:creator>
      <pubDate>Wed, 28 Aug 2019 15:07:56 +0000</pubDate>
      <link>https://forem.com/mattdionis/move-over-redux-apollo-client-as-a-state-management-solution-with-hooks-10jc</link>
      <guid>https://forem.com/mattdionis/move-over-redux-apollo-client-as-a-state-management-solution-with-hooks-10jc</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;On the Internal Tools team at &lt;a href="https://www.circle.com/" rel="noopener noreferrer"&gt;Circle&lt;/a&gt;, we recently modernized a legacy PHP app by introducing React components. Just a handful of months after this initiative began we have close to one-hundred React components in this app! 😲&lt;/p&gt;

&lt;p&gt;We recently reached a point where we found ourselves reaching for a state management solution. Note that it took many months and dozens of components before we reached this point. State management is often a tool that teams reach for well before they need it. While integrating a state management solution into an application no doubt comes with many benefits it also introduces complexity so don’t reach for it until you truly need it.&lt;/p&gt;

&lt;p&gt;Speaking of complexity, one complaint about the typical “go-to” state management solution, &lt;a href="https://redux.js.org/" rel="noopener noreferrer"&gt;Redux&lt;/a&gt;, is that it requires too much boilerplate and can be difficult to hit-the-ground-running with. In this post, we will look at a more lightweight solution which comes with the added benefit of providing some basic GraphQL experience for those who choose to use it.&lt;/p&gt;

&lt;p&gt;On the Circle 🛠 team, we know that our future stack includes GraphQL. In fact, in the ideal scenario, we would have a company-wide data graph at some point and access and mutate data consistently through GraphQL. However, in the short-term, we were simply looking for a low-friction way to introduce GraphQL to a piece of the stack and allow developers to wrap their heads around this technology in a low-stress way. GraphQL as a client-side state management solution using libraries such as &lt;a href="https://github.com/apollographql/apollo-client" rel="noopener noreferrer"&gt;apollo-client&lt;/a&gt; felt like the perfect way to get started. Let’s take a look at the high-level implementation of a proof-of-concept for this approach!&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring the client
&lt;/h2&gt;

&lt;p&gt;First, there are a number of packages we’ll need to pull in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add @apollo/react-hooks apollo-cache-inmemory
apollo-client graphql graphql-tag react react-dom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below you’ll find &lt;code&gt;index.js&lt;/code&gt; on the client in its entirety. We’ll walk through the client-side schema specific pieces next:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-dom&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;graphql-tag&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ApolloClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apollo-client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ApolloProvider&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@apollo/react-hooks&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;InMemoryCache&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apollo-cache-inmemory&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;userSettings&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./userSettings&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;typeDefs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt;&lt;span class="s2"&gt;`
  type AppBarColorSetting {
    id: Int!
    name: String!
    setting: String!
  }
  type Query {
    appBarColorSetting: AppBarColorSetting!
  }
  type Mutation {
    updateAppBarColorSetting(setting: String!): AppBarColorSetting!
  }
`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;resolvers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;appBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;userSettings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;appBarColorSetting&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;Mutation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;updateAppBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;setting&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;userSettings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;appBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;setting&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;userSettings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;appBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ApolloClient&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;InMemoryCache&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;freezeResults&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="nx"&gt;typeDefs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;resolvers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;assumeImmutableResults&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TogglesApp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ApolloProvider&lt;/span&gt; &lt;span class="na"&gt;client&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ApolloProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;TogglesApp&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;,&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, we define &lt;code&gt;typeDefs&lt;/code&gt; and &lt;code&gt;resolvers&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;AppBarColorSetting&lt;/code&gt; type will have required &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;name&lt;/code&gt;, and &lt;code&gt;setting&lt;/code&gt; fields. This will allow us to fetch and mutate the app bar’s color through GraphQL queries and mutations!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;AppBarColorSetting&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;!&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;!&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;setting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;!&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next up, we define the &lt;code&gt;Query&lt;/code&gt; type so that we can fetch the &lt;code&gt;appBarColorSetting&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Query&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;appBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;AppBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;!&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, you guessed it, we need to define the &lt;code&gt;Mutation&lt;/code&gt; type so that we can update &lt;code&gt;appBarColorSetting&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Mutation&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;updateAppBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;setting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;!):&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;AppBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;!&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we set up our client. Often, you will find yourself instantiating &lt;code&gt;ApolloClient&lt;/code&gt; with a &lt;code&gt;link&lt;/code&gt; property. However, since we have added a &lt;code&gt;cache&lt;/code&gt; and &lt;code&gt;resolvers&lt;/code&gt;, we do not need to add a &lt;code&gt;link&lt;/code&gt;. We do, however, add a couple of properties that may look unfamiliar. As of apollo-client 2.6, you can set an &lt;code&gt;assumeImmutableResults&lt;/code&gt; property to &lt;code&gt;true&lt;/code&gt; to let apollo-client know that you are confident you are not modifying cache result objects. This can, potentially, unlock substantial performance improvements. To enforce immutability, you can also add the &lt;code&gt;freezeResults&lt;/code&gt; property to &lt;code&gt;inMemoryCache&lt;/code&gt; and set it to &lt;code&gt;true&lt;/code&gt;. Mutating frozen objects will now throw a helpful exception in strict mode in non-production environments. To learn more, read the &lt;a href="https://blog.apollographql.com/whats-new-in-apollo-client-2-6-b3acf28ecad1" rel="noopener noreferrer"&gt;&lt;em&gt;“What’s new in Apollo Client 2.6”&lt;/em&gt;&lt;/a&gt; post from &lt;a href="https://twitter.com/benjamn" rel="noopener noreferrer"&gt;Ben Newman&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ApolloClient&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;InMemoryCache&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;freezeResults&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="nx"&gt;typeDefs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;resolvers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;assumeImmutableResults&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it! Now, simply pass this &lt;code&gt;client&lt;/code&gt; to &lt;code&gt;ApolloProvider&lt;/code&gt; and we’ll be ready to write our query and mutation! 🚀&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TogglesApp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ApolloProvider&lt;/span&gt; &lt;span class="na"&gt;client&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ApolloProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Querying client-side data
&lt;/h2&gt;

&lt;p&gt;We’re now going to query our client cache using GraphQL. Note that in this proof-of-concept, we simply define the initial state of our &lt;code&gt;userSettings&lt;/code&gt; in a JSON blob:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"appBarColorSetting"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"App Bar Color"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"setting"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"primary"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"__typename"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"AppBarColorSetting"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note the need to define the type with the &lt;code&gt;__typename&lt;/code&gt; property.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We then define our query in its own &lt;code&gt;.js&lt;/code&gt; file. You could choose to define this in the same file the query is called from or even in a &lt;code&gt;.graphql&lt;/code&gt; file though.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;graphql-tag&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;APP_BAR_COLOR_SETTING_QUERY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt;&lt;span class="s2"&gt;`
  query appBarColorSetting {
    appBarColorSetting @client {
      id
      name
      setting
    }
  }
`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;APP_BAR_COLOR_SETTING_QUERY&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The most important thing to notice about this query is the use of the &lt;code&gt;@client&lt;/code&gt; directive. We simply need to add this to the &lt;code&gt;appBarColorSetting&lt;/code&gt; query as it is client-specific. Let’s take a look at how we call this query next:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useQuery&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@apollo/react-hooks&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;AppBar&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@material-ui/core/AppBar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Toolbar&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@material-ui/core/Toolbar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Typography&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@material-ui/core/Typography&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;IconButton&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@material-ui/core/IconButton&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;MenuIcon&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@material-ui/icons/Menu&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;SettingsComponent&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./components/SettingsComponent&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;APP_BAR_COLOR_SETTING_QUERY&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./graphql/APP_BAR_COLOR_SETTING_QUERY&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;APP_BAR_COLOR_SETTING_QUERY&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Loading...&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AppBar&lt;/span&gt; &lt;span class="na"&gt;position&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"static"&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;appBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setting&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Toolbar&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;IconButton&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"inherit"&lt;/span&gt; &lt;span class="na"&gt;aria-label&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Menu"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MenuIcon&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;IconButton&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Typography&lt;/span&gt; &lt;span class="na"&gt;variant&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"h6"&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"inherit"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            State Management with Apollo
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Typography&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Toolbar&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AppBar&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;SettingsComponent&lt;/span&gt;
        &lt;span class="na"&gt;setting&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;
          &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;appBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setting&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;secondary&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: we are using &lt;a href="https://material-ui.com/" rel="noopener noreferrer"&gt;Material-UI&lt;/a&gt; in this app, but obviously the UI framework choice is up to you.&lt;/em&gt; 🤷‍♂️&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;APP_BAR_COLOR_SETTING_QUERY&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We show a basic loading indicator and then render the app bar with &lt;code&gt;data.appBarColorSetting.setting&lt;/code&gt; passed into the &lt;code&gt;color&lt;/code&gt; attribute. If you are using the Apollo Client Developer Tools, you’ll be able to clearly see this data sitting in the cache.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F0w9nz0yedvosgxanxev4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F0w9nz0yedvosgxanxev4.png" alt="Apollo State Management example screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Mutating client-side data and updating the cache
&lt;/h2&gt;

&lt;p&gt;You may have noticed this block of code in our &lt;code&gt;App&lt;/code&gt; component. This simply alternates the value of &lt;code&gt;setting&lt;/code&gt; based on its current value and passes it to our &lt;code&gt;SettingsComponent&lt;/code&gt;. We will take a look at this component and how it triggers a GraphQL mutation next.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;SettingsComponent&lt;/span&gt;
  &lt;span class="na"&gt;setting&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;appBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setting&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;secondary&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, let’s take a peek at our mutation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;graphql-tag&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UPDATE_APP_BAR_COLOR_SETTING_MUTATION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt;&lt;span class="s2"&gt;`
  mutation updateAppBarColorSetting($setting: String!) {
    updateAppBarColorSetting(setting: $setting) @client
  }
`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;UPDATE_APP_BAR_COLOR_SETTING_MUTATION&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again, notice the use of the &lt;code&gt;@client&lt;/code&gt; directive for our client-side &lt;code&gt;updateAppBarColorSetting&lt;/code&gt; mutation. This mutation is very simple: pass in a required setting string and update the setting.&lt;/p&gt;

&lt;p&gt;Below you will find all the code within our &lt;code&gt;SettingsComponent&lt;/code&gt; which utilizes this mutation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useMutation&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@apollo/react-hooks&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@material-ui/core/Button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;UPDATE_APP_BAR_COLOR_SETTING_MUTATION&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../graphql/UPDATE_APP_BAR_COLOR_SETTING_MUTATION&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;APP_BAR_COLOR_SETTING_QUERY&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../graphql/APP_BAR_COLOR_SETTING_QUERY&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;SettingsComponent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;setting&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;updateUserSetting&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMutation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;UPDATE_APP_BAR_COLOR_SETTING_MUTATION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;variables&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;setting&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readQuery&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
          &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;APP_BAR_COLOR_SETTING_QUERY&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;

        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dataClone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;appBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;appBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nx"&gt;setting&lt;/span&gt;
          &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;

        &lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeQuery&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
          &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;APP_BAR_COLOR_SETTING_QUERY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;dataClone&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;marginTop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;50px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;variant&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"outlined"&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"primary"&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;updateUserSetting&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        Change color
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;SettingsComponent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The interesting piece of this code that we want to focus on is the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;updateUserSetting&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMutation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;UPDATE_APP_BAR_COLOR_SETTING_MUTATION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;variables&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;setting&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readQuery&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;APP_BAR_COLOR_SETTING_QUERY&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;

      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dataClone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;appBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;appBarColorSetting&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="nx"&gt;setting&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;};&lt;/span&gt;

      &lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeQuery&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;APP_BAR_COLOR_SETTING_QUERY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;dataClone&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we make use of the apollo/react-hooks &lt;code&gt;useMutation&lt;/code&gt; hook, pass it our mutation and variables, then update the cache within the update method. We first read the current results for the &lt;code&gt;APP_BAR_COLOR_SETTING_QUERY&lt;/code&gt; from the cache then update &lt;code&gt;appBarColorSetting.setting&lt;/code&gt; to the setting passed to this component as a &lt;code&gt;prop&lt;/code&gt;, then write the updated &lt;code&gt;appBarColorSetting&lt;/code&gt; back to &lt;code&gt;APP_BAR_COLOR_SETTING_QUERY&lt;/code&gt;. Notice that we do &lt;strong&gt;not&lt;/strong&gt; update the &lt;code&gt;data&lt;/code&gt; object directly, but instead make a clone of it and update &lt;code&gt;setting&lt;/code&gt; within the clone, then write the cloned &lt;code&gt;data&lt;/code&gt; object back to the cache. This triggers our app bar to update with the new color! We are now utilizing apollo-client as a client-side state management solution! 🚀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fge78pf8wcils29wk4wcx.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fge78pf8wcils29wk4wcx.gif" alt="Apollo State Management in action gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;p&gt;If you’d like to dig into the code further, the &lt;a href="https://codesandbox.io/s/eloquent-johnson-fym98" rel="noopener noreferrer"&gt;CodeSandbox can be found here&lt;/a&gt;. This is admittedly a very contrived example but it shows how easy it can be to &lt;a href="https://www.apollographql.com/docs/react/essentials/local-state" rel="noopener noreferrer"&gt;leverage apollo-client as a state management solution&lt;/a&gt;. This can be an excellent way to introduce GraphQL and the Apollo suite of libraries and tools to a team who has little to no GraphQL experience. Expanding use of GraphQL is simple once this basic infrastructure is in place.&lt;/p&gt;

&lt;p&gt;I would love to hear thoughts and feedback from everyone and I hope you learned something useful through this post!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>graphql</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Never Too Late to Learn: My (meandering) path to a career in software engineering</title>
      <dc:creator>Matt Dionis</dc:creator>
      <pubDate>Tue, 27 Aug 2019 21:02:22 +0000</pubDate>
      <link>https://forem.com/mattdionis/never-too-late-to-learn-my-meandering-path-to-a-career-in-software-engineering-1p97</link>
      <guid>https://forem.com/mattdionis/never-too-late-to-learn-my-meandering-path-to-a-career-in-software-engineering-1p97</guid>
      <description>&lt;p&gt;If you've ever considered pursuing a career in software engineering but thought you were too old or that your education and career path up to this point weren't a fit, think again! My path to a career in software engineering is detailed below and let's just say it was not a straight line, but it was well worth it!&lt;/p&gt;

&lt;h2&gt;
  
  
  The weather geek
&lt;/h2&gt;

&lt;p&gt;For as long as I can remember I have been fascinated by the weather. Some of my fondest memories as a child were peering out the window as a severe thunderstorm rolled in or waking up in the morning to a raging blizzard outside. My favorite number was, and still is, 56 due to the fact that The Weather Channel was 56 on our cable package.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F89wioabkouyurz7s208p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F89wioabkouyurz7s208p.png" alt="The Weather Channel logo"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Old school Weather Channel logo. Oh, the memories!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Throughout my teenage years, I was the local weather spotter for Boston's ABC affiliate. I would call in local conditions and snowfall amounts during storms and would be mentioned on-air once in awhile. I knew my future career was going to be in meteorology and no one could tell me anything different.&lt;/p&gt;

&lt;p&gt;I was a solid student throughout my childhood and decided to only apply to one school, Penn State University. Penn State has one of the best, if not &lt;strong&gt;the&lt;/strong&gt; best, &lt;a href="http://www.met.psu.edu/" rel="noopener noreferrer"&gt;meteorology programs&lt;/a&gt; in the nation. I received my acceptance letter before Halloween of my senior year of high school. Everything was falling into place for this future meteorologist…or so I thought.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total lines of code written by age 18: 0&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Skills gained which would eventually help my engineering career: embracing a passion (meteorology) and being a self-starter in learning more about a field&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A national tragedy and a change of course
&lt;/h2&gt;

&lt;p&gt;Within the first month of college, my classmates and I were informed that there was a great chance &lt;strong&gt;none&lt;/strong&gt; of us would graduate with a Meteorology degree. I remember all of us laughing out loud. We had all been weather geeks since we could walk. Noooo chance we would change majors.&lt;/p&gt;

&lt;p&gt;By the beginning of my sophomore year of college, I started to get bored with my meteorology courses. I loved tornados, hurricanes, blizzards but these extreme weather events do not happen very often. I remember overhearing classmates arguing about whether that night's low temperature would be 37º or 38º one day and all I was concerned with was where I was going to party that night. It was clear that I needed to make a change, but when you've been known as the "future meteorologist" since age five it can be very difficult to tell those you love that that dream is over.&lt;/p&gt;

&lt;p&gt;I had my first Computer Science course scheduled for the fall of 2001 but &lt;strong&gt;after just one class&lt;/strong&gt; I dropped it. I decided that computer science was just not for me and my time was better spent in a different class. Oh, silly 20-year-old me ;)&lt;/p&gt;

&lt;p&gt;My sophomore year began in the fall of 2001 and on September 11 any childhood innocence I may have had left was gone. Meteorology suddenly felt even less important to me as I began to look for a major, and a future career, where I could have a greater impact.&lt;/p&gt;

&lt;p&gt;Around this same time, I attended a free speaker series event on the University Park campus. Chuck D of Public Enemy fame was the speaker that evening. I still remember to this day when he looked out at the audience and urged us, students, not to &lt;em&gt;"waste our time at a great university pursuing someone else's dream"&lt;/em&gt;. That was the push I needed and the very next day I began filling out paperwork to change my major.&lt;/p&gt;

&lt;p&gt;I moved to Washington D.C. after graduating from Penn State and within a year was working as a Data Analyst on an Immigration and Customs Enforcement (ICE) contract.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total lines of code written by age 22: 0&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Skills gained which would eventually help my engineering career: time management, advanced mathematics, improved logical thinking&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Jaded and restless
&lt;/h2&gt;

&lt;p&gt;I entered my career in Homeland Security with a vision that I would be "protecting the country from terrorists". This is &lt;strong&gt;not&lt;/strong&gt; what I experienced in reality. It quickly became apparent to me that my job was mostly busy work and that the contractor I was working for was much more interested in securing more Federal contracts while appearing to "fight terrorism" than actually fighting terrorism. In my 2.5 years on the job, I can honestly admit that my work contributed to zero terrorist apprehensions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbbkazznuc3qc37d4iibf.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbbkazznuc3qc37d4iibf.jpeg" alt="Fitness modeling profile"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fitness modeling photoshoot circa 2007&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I was pretty frustrated at this point but thankfully had the gym as an outlet. Every day after work I would spend a solid two hours lifting weights. I would then go home and prepare eggs, oatmeal, chicken, and sweet potatoes for the next day's meals. This lifestyle eventually led to a couple of local photoshoots and the opportunity to work with a manager to further this side career. I did some work for Under Armour and Simpson Racing and quickly got the itch to move West to Hollywood to see what I could make out of this opportunity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total lines of code written by age 25: 0&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Skills gained which would eventually help my engineering career: even stronger self-starter skills, ability to focus on the task-at-hand and remove distractions&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hollywood dreams
&lt;/h2&gt;

&lt;p&gt;I quit my stable job with great benefits while my parents were vacationing overseas and broke the news to them over the phone the day they returned. I do &lt;strong&gt;not&lt;/strong&gt; recommend this strategy for breaking news like this. It did not go over well, to say the least.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fwy5nm9e8yxsmy4oe5jg9.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fwy5nm9e8yxsmy4oe5jg9.jpeg" alt="The Hollywood Sign"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The backdrop to an interesting 15 months of my life&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After arriving in LA, I found a job working as a graveyard shift Front Desk Agent at a &lt;a href="https://www.morganshotelgroup.com/mondrian/mondrian-los-angeles" rel="noopener noreferrer"&gt;hotel on the Sunset Strip&lt;/a&gt;. My plan was to work nights, hit the gym in the morning, and audition for acting roles in the afternoon. This plan turned out to be very naive. I auditioned for a grand total of zero roles as I had failed to take sleep into consideration. I never really got accustomed to the overnight shift and felt like a zombie most days.&lt;/p&gt;

&lt;p&gt;I made the decision to move back to my hometown in late 2008 just as the economy was collapsing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total lines of code written by age 26: 0&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Skills gained which would eventually help my engineering career: the ability to fight through adversity, communication skills, "debugging" (in this case in support of solving hotel guest issues)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Return to the East Coast
&lt;/h2&gt;

&lt;p&gt;I moved back to the East Coast at the very end of 2008 when the economy had hit rock bottom. It took me almost a full year to find another job. In hindsight, I wish I had begun learning to code at this point but it never crossed my mind.&lt;/p&gt;

&lt;p&gt;I worked as a Data Analyst on a temporary contract for a little over a year. I had no benefits: no healthcare, zero vacation days, no opportunity to advance. Thankfully, my wife encouraged me to pursue a career in &lt;a href="https://en.wikipedia.org/wiki/Actuarial_science" rel="noopener noreferrer"&gt;actuarial science&lt;/a&gt;. I had a solid math background and actuarial careers pay well so I started studying!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total lines of code written by age 29: 0&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Skills gained which would eventually help my engineering career: analytical skills&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Avoiding risk
&lt;/h2&gt;

&lt;p&gt;I passed the first two actuarial exams on my own which led to an opportunity to work at a &lt;a href="https://www.hanover.com/" rel="noopener noreferrer"&gt;local insurance company&lt;/a&gt;. This was a huge step up from my prior temp role. This position is where I began to dabble in some "programming" in a way. Most of my days were spent in massive Microsoft Excel files updating and improving macros. I found that I really enjoyed this work although it still felt fairly tedious.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ftajpu9w0dt7rfy7yhbrf.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ftajpu9w0dt7rfy7yhbrf.jpeg" alt="Example actuarial exam problem"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;A sample problem from an actuarial exam. I do not miss those days!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I struggled mightily with the third actuarial exam and ended up transitioning off of the exam track and into an actuarial technician role. This role afforded me the opportunity to begin working with SQL Server. I took to this from day one and had a lot of fun learning SQL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total lines of code written by age 32: 0 (unless you count Excel macros and SQL)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Skills gained which would eventually help my engineering career: "programming" Excel macros, SQL&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Embracing risk
&lt;/h2&gt;

&lt;p&gt;Around this same time, one of my best friends from high school and I decided to work on a health and fitness startup. The basic idea was to connect the millions of health and fitness-related photos shared on social media (meals, supplements, workouts, etc.) to health and fitness companies. You can think of it as a healthy living rewards platform. We called it &lt;a href="http://outliermagazine.co/matt-dionis-conquerfit-interview/" rel="noopener noreferrer"&gt;ConquerFit&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1nkbi447p621uk762wti.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1nkbi447p621uk762wti.jpeg" alt="ConquerFit app prototype screenshot"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;An early prototype of the ConquerFit app&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We outsourced development of the ConquerFit app to a local dev team and they delivered exactly what we wanted for our MVP. We quickly realized, however, that our friends and family funding had been blown through and we had a lot of features that needed to be added to the app before it was ready for general public release.&lt;/p&gt;

&lt;p&gt;I decided to teach myself to code in order to build the "v2" version of our app.&lt;/p&gt;

&lt;p&gt;I dove in head first starting with &lt;a href="https://www.codecademy.com/" rel="noopener noreferrer"&gt;Codecademy&lt;/a&gt; which I found to be an excellent first resource. After working through all of the JavaScript, HTML, CSS, and SQL material on Codecademy, I moved on to &lt;a href="https://teamtreehouse.com/" rel="noopener noreferrer"&gt;Treehouse&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I felt confident at this point and began hacking on some small sample projects. I cannot stress enough how important it is to begin working on an actual project early on in your learning journey. Working through tutorials is one thing, building an app is quite another. You'll quickly get familiar with &lt;a href="https://git-scm.com/" rel="noopener noreferrer"&gt;git&lt;/a&gt; and &lt;a href="https://github.com/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;, &lt;a href="https://www.npmjs.com/" rel="noopener noreferrer"&gt;npm&lt;/a&gt;, &lt;a href="https://developers.google.com/web/tools/chrome-devtools/" rel="noopener noreferrer"&gt;browser dev tools&lt;/a&gt;, and much more.&lt;/p&gt;

&lt;p&gt;The sample project I spent most of my time on was something I called "MobSeen". This application focused on sports events and allowed users to view Instagram photos shared in and around sporting events in near real-time. In order to build this app, I needed to gain a deeper understanding of Node.JS, AngularJS and setting up and managing a database. This turned out to be a great learning experience!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F4ptwwv5t8d318b7zf4fn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F4ptwwv5t8d318b7zf4fn.png" alt="MobSeen app screenshot"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The MobSeen app showing photos at Super Bowl XLIX!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I &lt;strong&gt;loved&lt;/strong&gt; the process of learning, building, stumbling, learning some more, and repeating over and over again. What I found that I did &lt;strong&gt;not&lt;/strong&gt; love was running a startup and thinking about fundraising, marketing, accounting, etc. ConquerFit would fade away but my newfound passion for web development would propel my career forward.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total lines of code written by age 32: many 😁&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Skills gained which would eventually help my engineering career: HTML, CSS, JavaScript, git, GitHub, npm, browser dev tools, debugging&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Given a chance
&lt;/h2&gt;

&lt;p&gt;I was very hesitant to apply for software engineering jobs at first as I never quite felt "ready". Thankfully, my wife urged me to go for it and I followed her advice. I was able to get on the &lt;a href="https://hired.com/" rel="noopener noreferrer"&gt;Hired&lt;/a&gt; platform in the spring of 2015. I originally was only interested in jobs in Central Massachusetts as I wanted to avoid a commute. My recruiter, however, convinced me to expand my search area to Boston and I am so thankful that I did. I interviewed with a half dozen companies before receiving and accepting an offer from &lt;a href="https://www.circle.com/" rel="noopener noreferrer"&gt;Circle&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;My first role in this field was as a Software Engineer on the internal tools team at Circle. I was, and continue to be, incredibly grateful to the team at Circle for giving me a chance. I had an awesome manager and was surrounded by an intelligent, hard-working and collaborative team from day one. I can't say enough about how comfortable they made me feel and how much I learned over those first couple of weeks, months, and years in the industry.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total lines of PRODUCTION code written by age 34: many 😁&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Giving back
&lt;/h2&gt;

&lt;p&gt;I have spent the last eighteen months in Tech Lead/Engineering Manager roles which have allowed me to further improve my communication, prioritization, planning and management skills. I am focused on giving back to more junior developers and career-changers at this point through blogging, speaking at conferences, building video courses, and mentorship.&lt;/p&gt;

&lt;p&gt;Take it from me: you are &lt;strong&gt;not&lt;/strong&gt; too old to start coding, and your seemingly unrelated career path to this point &lt;strong&gt;will&lt;/strong&gt; help you to be a better engineer in the long run. Start learning, start building, and never stop asking questions! In fact, feel free to reach out to me &lt;a href="https://twitter.com/MattDionis" rel="noopener noreferrer"&gt;@mattdionis&lt;/a&gt; or &lt;a href="//mailto:mattdionis@gmail.com"&gt;mattdionis@gmail.com&lt;/a&gt; with any and all questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources that have helped me (and could help you)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Learning platforms
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.codecademy.com/" rel="noopener noreferrer"&gt;Codecademy&lt;/a&gt; (solid for beginners)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://teamtreehouse.com/" rel="noopener noreferrer"&gt;Treehouse&lt;/a&gt; (great next step after Codecademy)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.pluralsight.com/" rel="noopener noreferrer"&gt;Pluralsight&lt;/a&gt; (more advanced, deep dives into frameworks/libraries)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://egghead.io/" rel="noopener noreferrer"&gt;Egghead.io&lt;/a&gt; (awesome JavaScript content)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Instructors/bloggers
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://medium.com/@samerbuna" rel="noopener noreferrer"&gt;Samer Buna&lt;/a&gt; (especially love his Node.JS material)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://overreacted.io/" rel="noopener noreferrer"&gt;Dan Abramov&lt;/a&gt; (incredible deep dives into React)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://blog.apollographql.com/" rel="noopener noreferrer"&gt;The Apollo GraphQL blog&lt;/a&gt; (great for beginner and experienced GraphQL devs alike)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Twitter follows
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://twitter.com/sarah_edo" rel="noopener noreferrer"&gt;Sarah Drasner&lt;/a&gt; (animations, VueJS, and so much more)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://twitter.com/sxywu" rel="noopener noreferrer"&gt;Shirley Wu&lt;/a&gt; (data visualization awesomeness)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://twitter.com/NadiehBremer" rel="noopener noreferrer"&gt;Nadieh Bremer&lt;/a&gt; (⬆️ ditto)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://twitter.com/swyx" rel="noopener noreferrer"&gt;Shawn Wang&lt;/a&gt; (JAMstack!)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://twitter.com/John_Papa" rel="noopener noreferrer"&gt;John Papa&lt;/a&gt; (Angular!)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Podcasts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://reactpodcast.simplecast.fm/" rel="noopener noreferrer"&gt;React Podcast&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devchat.tv/react-round-up/" rel="noopener noreferrer"&gt;React Round Up&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://undefined.fm/" rel="noopener noreferrer"&gt;Undefined&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://fullstack.health/" rel="noopener noreferrer"&gt;Fullstack Health&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Good luck!!!&lt;/em&gt;&lt;/strong&gt; 👨‍💻&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>career</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
