<?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: Peter Kang</title>
    <description>The latest articles on Forem by Peter Kang (@pswk1).</description>
    <link>https://forem.com/pswk1</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%2F420276%2F7ea781c5-4445-43b6-9493-e0d5a8fbd83b.jpeg</url>
      <title>Forem: Peter Kang</title>
      <link>https://forem.com/pswk1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/pswk1"/>
    <language>en</language>
    <item>
      <title>Appreciating Maps in Javascript</title>
      <dc:creator>Peter Kang</dc:creator>
      <pubDate>Thu, 14 Jan 2021 23:57:46 +0000</pubDate>
      <link>https://forem.com/pswk1/appreciating-maps-in-javascript-3b9b</link>
      <guid>https://forem.com/pswk1/appreciating-maps-in-javascript-3b9b</guid>
      <description>&lt;p&gt;I've been loving using Maps in JS lately for a variety of purposes. A simple one is to go through an iterable and count the occurrence of each of the items.&lt;/p&gt;

&lt;p&gt;For example, I'll have a array of grocery items and a new instance of a Map to store those items and their respective number of occurrences:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--69I4fEus--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ot8sml6wvikq9wvpz0kd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--69I4fEus--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ot8sml6wvikq9wvpz0kd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pretty cool! The loop iterates through the grocery list and checks if it already exists in the Map. If it doesn't, it'll create a new key-value pair with the item as key and 1 as its value. If it does, then it'll increment the existing value.&lt;/p&gt;

&lt;p&gt;This was how I'd been going about it for a while, then I realized we can make this much more concise.&lt;br&gt;
We'll remove any conditionals, and go straight to using the set method. The item will be set as a key from the get-go, and in the value parameter, we'll set up the get method to get the associated value. &lt;/p&gt;

&lt;p&gt;We've set a default value as 0 by utilizing the logical OR operator, so if that get value returns undefined (aka it doesn't exist), it'll have something to fall back on. Lastly, it'll increment by 1 to set the value as 1 if the item doesn't exist,  or it'll increment an existing value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8xD0i7hl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/p0a0l4rx1pilv3qhio1h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8xD0i7hl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/p0a0l4rx1pilv3qhio1h.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I do feel like the first approach is a bit more intuitive, however knowing how default values and logical operators, well, operate would be so 🔥 with the second approach.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>firstyearincode</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Mindset and Encouragement</title>
      <dc:creator>Peter Kang</dc:creator>
      <pubDate>Wed, 26 Aug 2020 18:46:28 +0000</pubDate>
      <link>https://forem.com/pswk1/mindset-and-encouragement-1h8c</link>
      <guid>https://forem.com/pswk1/mindset-and-encouragement-1h8c</guid>
      <description>&lt;p&gt;The following is an article that I wrote a while back mainly for myself in times of slump or discouragement. Who would have thought the past me would have ended up helping future me! I hope it provides some insight and encouragement for anyone else in the same situation.&lt;/p&gt;




&lt;p&gt;As a second-generation Asian-American, I was raised in an environment that required a stoic temperament and expressions of vulnerability were seen as foreign. However, as we navigate these uncertain times, I wanted to break that cycle and share a few important tips to for creating a mindset that I found valuable in order to conquer the feelings of anxiety, lack of self-worth, or imposter syndrome that individuals like myself may encounter, i.e. bootcamp grads trying to land a position. But really, these can apply to anyone in a less than favorable employment position as a result of COVID-19.&lt;/p&gt;

&lt;p&gt;Practicality&lt;/p&gt;

&lt;p&gt;Unfortunately, the reality is that a number of bootcamp students are under the illusion that after however many weeks, a developer position will be handed to them on a silver platter. Finishing bootcamp is just scratching the surface, and the thought that there is always something to learn every day is something that should fill us with excitement every morning that we're blessed to wake up. Self-awareness is incredibly important. If the process of trying to solve a problem, finally solving it, and adding that solution to your toolbox doesn't excite you, or at the very least isn't tolerable, some self-reflection may be in order. In my short experience, the world of development is extremely welcoming, but we have to meet it halfway.&lt;/p&gt;

&lt;p&gt;Resilience&lt;/p&gt;

&lt;p&gt;Being stubborn is something that I have been chastised for in the past, but who would have thought that it would have come so in handy as a developer? Many budding devs feel a lot of pressure to produce great projects, really fast. The key however, is to get at least 1% better each day. Just 1%. Go above and beyond if you can, but 1% is the minimum requirement. Whether that be fixing a bug, learning a small part of a new framework, or improving your understanding of something you've already experienced. Just. 1%.&lt;/p&gt;

&lt;p&gt;Optimism&lt;/p&gt;

&lt;p&gt;At the end of the day, our time will come my friends. It may not be tomorrow, next month, or even next year. But it will come. Focus on building on that 1% every day and before you know it, you'll look back and won't even recognize the code that you used to write. It's easier said than done, but I wanted to offer some encouragement as I know for a fact that there are countless others who feel similarly and are going through the same trials.&lt;/p&gt;

&lt;p&gt;I hope that this does not come off as pseudo-philosophical or entirely preachy. Remembering these things has been an immense benefit to my mindset in these times and if it helps one person tackle that problem just one more time, I'll be gratified.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>mentalhealth</category>
    </item>
    <item>
      <title>Exploring GraphQL</title>
      <dc:creator>Peter Kang</dc:creator>
      <pubDate>Tue, 18 Aug 2020 01:29:36 +0000</pubDate>
      <link>https://forem.com/pswk1/exploring-graphql-i0i</link>
      <guid>https://forem.com/pswk1/exploring-graphql-i0i</guid>
      <description>&lt;p&gt;As I broaden my developer skillset, I've discovered that reiterating is a great method of reinforcing what I learned, and writing is one of the best mediums to do so. Thank you for visiting and I hope that you're able to take something away from this as well!&lt;/p&gt;

&lt;h1&gt;
  
  
  What is GraphQL?
&lt;/h1&gt;

&lt;p&gt;GraphQL is a query language that was created by Facebook to address the data fetching challenges faced when attempting to get data from server to client. Contrary to popular belief, it can be used with many programming languages to implement a graph server.&lt;/p&gt;

&lt;h1&gt;
  
  
  GraphQL vs REST API
&lt;/h1&gt;

&lt;p&gt;Generally, fetching large amounts of data from REST API's may end up tricky since requests may use many different endpoints, resulting in a unsavory response time.&lt;/p&gt;

&lt;p&gt;With GraphQL, we can define and send a query to a GraphQL server. A query looks similar to a JSON object. Let's say we want to get the data of a certain Pokémon. An example query would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{ 
  pokemon {
    name
    type
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response looks similar to the query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{ 
  "data": {
    "pokemon" {
      "name": "blastoise"
      "type": "water"
     }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we change the data that we need, we can update query by adding to it. It is nested and issued at once! For example, we can add more fields after &lt;code&gt;type&lt;/code&gt; and there may even be more nested fields after that. &lt;/p&gt;

&lt;p&gt;One benefit that came to mind was loading UI components. We can utilize one call to get the data that we need and populate the component accordingly! So neat.&lt;/p&gt;

&lt;p&gt;For a more in-depth look (and quite frankly a much better explanation than I can provide at the moment) into REST vs GraphQL, I've found that this &lt;a href="https://www.youtube.com/watch?v=PeAOEAmR0D0"&gt;video&lt;/a&gt; does an excellent job.&lt;/p&gt;

&lt;h1&gt;
  
  
  Let's Try It! Github API/GraphiQL
&lt;/h1&gt;

&lt;p&gt;To try it out, we'll be using Github's GraphQL API and the GraphiQL interface. This is essentially an in-browser IDE that allows us to make queries to the Github API. We can get started &lt;a href="https://developer.github.com/v4/explorer/"&gt;here&lt;/a&gt;. We will need to be signed into a Github account, or make one if you don't have one yet. Both can be accomplished &lt;a href="https://github.com"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Queries
&lt;/h1&gt;

&lt;p&gt;When we build queries, we ask for the values of fields. The most basic field we can start with in the Github GraphQL Explorer is the &lt;code&gt;viewer&lt;/code&gt; field, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  viewer {

  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Within viewer, we can add a subfield of &lt;code&gt;login&lt;/code&gt; by nesting it within &lt;code&gt;viewer&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  viewer {
    login
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can hit the button that looks like the "play" symbol and the query will be sent to the server. The response looks very similar to a JSON object. If you have a username set up in your Github settings, it should be returned here. Otherwise, it may return &lt;code&gt;null&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--owSHRSc9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zf0e1hdxqums7w8mck0s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--owSHRSc9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zf0e1hdxqums7w8mck0s.png" alt="Alt Text" width="680" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition, you'll notice that there is some auto-complete behavior when entering fields. We can also access all the possible fields by hitting &lt;code&gt;ctrl + space&lt;/code&gt;. Try playing around with all the possible fields we can explore!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---Y5oy7bw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/z7q6awzwxtfuydgaxnfw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---Y5oy7bw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/z7q6awzwxtfuydgaxnfw.png" alt="Alt Text" width="368" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's get some more information like our bio, id, and profile picture. We can get this data by entering the fields &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;bio&lt;/code&gt;, and &lt;code&gt;avatarURL&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IxD9jA0w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/faeurb2mxr4kp8u819wq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IxD9jA0w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/faeurb2mxr4kp8u819wq.png" alt="Alt Text" width="880" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Arguments
&lt;/h1&gt;

&lt;p&gt;There are fields that can be take arguments. For example &lt;code&gt;repositoryOwner&lt;/code&gt; can take arguments to return data about just that. We can see that it takes &lt;code&gt;login&lt;/code&gt; as an argument. Let's look up Facebook, its &lt;code&gt;id&lt;/code&gt;, its path (the subfield is referred to as &lt;code&gt;resourcePath&lt;/code&gt;), and its &lt;code&gt;url&lt;/code&gt;. Please note that in GraphQL, we must use double quotes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SXSp7wS0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7i697nsgaes4qk502wxf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SXSp7wS0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7i697nsgaes4qk502wxf.png" alt="Alt Text" width="845" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some fields require arguments. Such a field is the &lt;code&gt;repository&lt;/code&gt; field. We can see that the &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;owner&lt;/code&gt; arguments are required since those two pieces of information are required to get a single repository. Let's look up GraphQL's GraphiQL repository and get its &lt;code&gt;description&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vgppI3en--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qqsliuvhu078en08skdd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vgppI3en--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qqsliuvhu078en08skdd.png" alt="Alt Text" width="880" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any attempts to make queries without required arguments will result in an error. For example, if we try to query &lt;code&gt;repository&lt;/code&gt; without the &lt;code&gt;owner&lt;/code&gt; argument, we would get the following error:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lvV3uVeT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bzr6j4hrnlfd9qo1cbbd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lvV3uVeT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bzr6j4hrnlfd9qo1cbbd.png" alt="Alt Text" width="381" height="179"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Schemas
&lt;/h1&gt;

&lt;p&gt;Fields are determined by GraphQL schemas. These schemas provide the object types used in our data, and they specify the types for all the values. An advantage of using the GraphiQL interface is that the schemas are well documented in the browser. &lt;/p&gt;

&lt;p&gt;In the Github GraphiQL interface, if we click on &lt;code&gt;Docs&lt;/code&gt; on the right side, we can see the available schemas.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6oZ8oO3L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ikulk0j683prsvn9xfbb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6oZ8oO3L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ikulk0j683prsvn9xfbb.png" alt="Alt Text" width="118" height="76"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have two root types, &lt;code&gt;query&lt;/code&gt; and &lt;code&gt;mutations&lt;/code&gt; the latter which we will go over later on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MA7ayU5p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0r9ax7zqowzrr1qdh2lm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MA7ayU5p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0r9ax7zqowzrr1qdh2lm.png" alt="Alt Text" width="421" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we click &lt;code&gt;query&lt;/code&gt; we are met with a list of all the possible fields that we can use.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JqTD8z8---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9gw9b3oteud4ebtmpp74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JqTD8z8---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9gw9b3oteud4ebtmpp74.png" alt="Alt Text" width="424" height="546"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's scroll down and click the &lt;code&gt;repository&lt;/code&gt; field. Once we do, we can see that it has two arguments, &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;owner&lt;/code&gt;. They are specified to have a &lt;code&gt;String&lt;/code&gt; type and the exclamation point denotes that they are required arguments. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WszgPPT3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/po4xddbxos0smokfuxvg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WszgPPT3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/po4xddbxos0smokfuxvg.png" alt="Alt Text" width="426" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Try exploring the &lt;code&gt;query&lt;/code&gt; schema and all the fields we can explore in the Github GraphQL API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Querying &lt;code&gt;__schema&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;What if we are outside the GraphiQL interface? We can query &lt;code&gt;__schema&lt;/code&gt; to check out the architecture and all the possible values. Let's do just that. We will query &lt;code&gt;__schema&lt;/code&gt;, and from there we will choose &lt;code&gt;queryType&lt;/code&gt;, which is one of two root types in the schema. In &lt;code&gt;queryType&lt;/code&gt;, we will query &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;description&lt;/code&gt;, and &lt;code&gt;fields&lt;/code&gt;. Finally, within &lt;code&gt;fields&lt;/code&gt;, we will query &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;description&lt;/code&gt; once more. The resulting query and response will look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ntCSvPqT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5pxspowu6t3mo1j0xdn9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ntCSvPqT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5pxspowu6t3mo1j0xdn9.png" alt="Alt Text" width="880" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that there is a description of the root &lt;code&gt;query&lt;/code&gt; type. After that, the response lists all the possible fields we can  utilize with their names and description. Neat!&lt;/p&gt;

&lt;h1&gt;
  
  
  Aliases
&lt;/h1&gt;

&lt;p&gt;Let's say that we want to query two repositories. We can utilize aliases to do so. For example we will query for the react-native and create-react-app repositories. In this case, I will give them aliases as &lt;code&gt;reactNativeRepo&lt;/code&gt; and &lt;code&gt;createReactAppRepo&lt;/code&gt;, respectively. Each of them will be followed by a colon, and their respective queries. In these queries, let's look for their respective names, descriptions, and URLs. They will be nested in one big query, like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dAhmYj2s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fixq32avmds8soy2oomy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dAhmYj2s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fixq32avmds8soy2oomy.png" alt="Alt Text" width="880" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Fragments
&lt;/h1&gt;

&lt;p&gt;Note that in our previous query, we are querying the same three fields. This doesn't seem like very DRY code, so we can utilize fragments. We can utilize fragments to shorten our code a bit and have reusable bits of our queries. The fragment will take this form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fragment fragmentName on objectType {
  fields
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, in our case, our fragment will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fragment repoInfo on Repository {
  id
  description
  homepageUrl
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we can include our fragment with a spread operator before it in our query. It will look like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nFlh8w3I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6vj1la7xsosksspbyh26.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nFlh8w3I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6vj1la7xsosksspbyh26.png" alt="Alt Text" width="880" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nice! We now have a reusable bit of query that we can use elsewhere without repeating the same fields.&lt;/p&gt;

&lt;h1&gt;
  
  
  Nested Fields
&lt;/h1&gt;

&lt;p&gt;Let's say we have the following query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  viewer {
     id
     name
     location
     repositories
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will get the following response:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4F7A_IKR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uolzgpgq5xq5qb8ciyow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4F7A_IKR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uolzgpgq5xq5qb8ciyow.png" alt="Alt Text" width="880" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;edges&lt;/code&gt; indicates a connection to another array of data. The field &lt;code&gt;node&lt;/code&gt; in this case represents a single repository. In addition, you'll notice the error message,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You must provide a &lt;code&gt;first&lt;/code&gt; or &lt;code&gt;last&lt;/code&gt; value to properly paginate the &lt;code&gt;repositories&lt;/code&gt; connection.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here, we must pass in an argument into &lt;code&gt;repositories&lt;/code&gt; so that  the server knows which repositories to look for. I'll pass in &lt;code&gt;last: 3&lt;/code&gt; to get the last three repositories, as well as &lt;code&gt;name&lt;/code&gt; in the &lt;code&gt;node&lt;/code&gt; field to get their names.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nT7fADiB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5dwmbunso8vd8vwun5t9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nT7fADiB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5dwmbunso8vd8vwun5t9.png" alt="Alt Text" width="880" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Check out the other arguments for &lt;code&gt;repositories&lt;/code&gt; for other ways you can query the repos! In addition, explore the &lt;code&gt;repositories&lt;/code&gt; field in the Docs and take note of what you see there.&lt;/p&gt;

&lt;p&gt;We can make a fairly complex query with multiple nested fields. The beauty of it is that we can grab large amount of data with just one call!&lt;/p&gt;

&lt;h1&gt;
  
  
  Operation Names
&lt;/h1&gt;

&lt;p&gt;We can add the word &lt;code&gt;query&lt;/code&gt; at the beginning of our queries. It will function the same way. However, in a codebase of complex queries, it may be hard to keep track of. As a result, we can add the word &lt;code&gt;query&lt;/code&gt; followed by an identifying name. &lt;/p&gt;

&lt;p&gt;For example, let's give our previous query a name of &lt;code&gt;getLastRepos&lt;/code&gt;. In addition, I'll duplicate the query and instead get the first three repos. This will be named &lt;code&gt;getFirstRepos&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YfqWPzsE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7w27sifi0655zb30hygw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YfqWPzsE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7w27sifi0655zb30hygw.png" alt="Alt Text" width="311" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a result, when we hit the play button to make the queries, we are given options to query because of the operation names we gave our queries. This can be deeply useful when we have many queries!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h6UwrECH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6n658xu2m98w62yew3xn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h6UwrECH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6n658xu2m98w62yew3xn.png" alt="Alt Text" width="241" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Variables
&lt;/h1&gt;

&lt;p&gt;Let's now explore the &lt;code&gt;organization&lt;/code&gt; field. I have the following query that search Facebooks first three members.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  organization(login:"facebook") {
    id
    name
    membersWithRole(first: 3) {
      edges {
        node {
          id
          name
        }
      }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, we can use variables to search other organizations using variables. First, let's reformat our query. First, we'll give our operation a clear name. Next, we'll pass in &lt;code&gt;$login: String!&lt;/code&gt; to our operation which indicates that the &lt;code&gt;login&lt;/code&gt; variable will be a String type and that is required.&lt;br&gt;
Next, in the &lt;code&gt;organization&lt;/code&gt; field, we'll replace "facebook" with &lt;code&gt;login&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;query getFirstThreeMembers($login: String!){
  organization(login: $login) {
    id
    name
    membersWithRole(first: 3) {
      edges {
        node {
          id
          name
        }
      }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, where do we define these variables? At the bottom of the interface, we notice a section we haven't used yet, &lt;code&gt;Query Variables&lt;/code&gt;. Let's bring it up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BQmk6Nd3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kvoeb9eo9iqgpoc1b6mw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BQmk6Nd3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kvoeb9eo9iqgpoc1b6mw.png" alt="Alt Text" width="767" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In there, we will define login, and this time we'll set it to "google". As a result, the first three members of Google's organization in Github will return in the response.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o7DjVXrX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s9vy4oaprtgkln3meofu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o7DjVXrX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s9vy4oaprtgkln3meofu.png" alt="Alt Text" width="872" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Awesome!&lt;/p&gt;

&lt;h1&gt;
  
  
  Mutations
&lt;/h1&gt;

&lt;p&gt;We've gotten data thus far, but how do we change it? In GraphQL we will utilize mutations. We can think of mutations as similar to PUT or DELETE requests when working with REST APIs. In GraphQL, we can send data as a payload in a mutation. The dataset is changed, and the API defines which mutations can be performed. Check out the Docs in the Github GraphiQL to see which mutations we can perform.&lt;/p&gt;

&lt;p&gt;For our demonstration purposes, I will be using a mutation to create an issue in one of my repositories. For these purposes, I've created a repository named graphql-tests. Its issues tab will can be found &lt;a href="https://github.com/pswk1/graphql-tests/issues"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I will write a query to find this repo and its ID, which we will need to make our mutation. Keep this ID closeby!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yqFp_fk6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lxqbm36638x4orwf0twv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yqFp_fk6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lxqbm36638x4orwf0twv.png" alt="Alt Text" width="880" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we'll write our mutation query. We will start with the mutation type, and give it a name, &lt;code&gt;createIssue&lt;/code&gt;. If we explore the docs for creating a new issue via mutation, we'll see that the payload consists of a &lt;code&gt;clientMutationId&lt;/code&gt; and &lt;code&gt;issue&lt;/code&gt;. We will create an input variable that contains our payload.&lt;/p&gt;

&lt;p&gt;Next, we will enter the &lt;code&gt;createIssue&lt;/code&gt; field with &lt;code&gt;input: $input&lt;/code&gt; as arguments. It will contain the aforementioned &lt;code&gt;clientMutationId&lt;/code&gt; and &lt;code&gt;issue&lt;/code&gt;, and within &lt;code&gt;issue&lt;/code&gt;, we'll include &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;body&lt;/code&gt;, and &lt;code&gt;title&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Qndf1t5q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/04mkcvxiim0h7aa7pn36.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Qndf1t5q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/04mkcvxiim0h7aa7pn36.png" alt="Alt Text" width="450" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Excellent! Now all we have to do is define our input variable.&lt;/p&gt;

&lt;p&gt;The input payload has two requirements, a unique &lt;code&gt;clientMutationId&lt;/code&gt; which we can set to whatever we'd like, and the &lt;code&gt;repositoryId&lt;/code&gt; which we got from our first query. In addition, we included &lt;code&gt;body&lt;/code&gt; and &lt;code&gt;title&lt;/code&gt; in our mutation query so let's include that as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MUKIz150--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cgt0uvv68fweyo1j8s40.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MUKIz150--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cgt0uvv68fweyo1j8s40.png" alt="Alt Text" width="534" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is a look at our query, variable, and response:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gCy8-XCv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vgu48gt5zkcc0o10tvp2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gCy8-XCv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vgu48gt5zkcc0o10tvp2.png" alt="Alt Text" width="880" height="530"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And finally, if we take a look at the repository on Github, we can see that the issue was created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wduXV4jp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/096jiiyaxoco6eqnp1mv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wduXV4jp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/096jiiyaxoco6eqnp1mv.png" alt="Alt Text" width="880" height="564"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Awesome! There are so many different mutations we can perform with this API alone. Each GraphQL API will have its queries and mutations documented so the possibilities are endless!&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I hope that this article provided you with some value and a way to get your feet wet with GraphQL. Writing it has been a great way to reinforce what I've learned thus far. Thank you for taking the time to read and explore.&lt;/p&gt;

&lt;p&gt;If you'd like to connect, reach me here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="//mailto:peeterkang@gmail.com"&gt;peeterkang@gmail.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.linkedin.com/in/peterswkang/"&gt;LinkedIn&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.pswk1.dev/"&gt;Portfolio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pswk1"&gt;Github&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>graphql</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
