<?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>DEV Community: Prashanth Krishnamurthy</title>
    <description>The latest articles on DEV Community by Prashanth Krishnamurthy (@prashanth1k).</description>
    <link>https://dev.to/prashanth1k</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%2F81509%2F9a978451-8748-4018-8929-2df3731a8251.jpg</url>
      <title>DEV Community: Prashanth Krishnamurthy</title>
      <link>https://dev.to/prashanth1k</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prashanth1k"/>
    <language>en</language>
    <item>
      <title>Commit to blog daily - it's smart and it's stupid</title>
      <dc:creator>Prashanth Krishnamurthy</dc:creator>
      <pubDate>Mon, 30 Sep 2019 00:00:00 +0000</pubDate>
      <link>https://dev.to/prashanth1k/commit-to-blog-daily-it-s-smart-and-it-s-stupid-jb1</link>
      <guid>https://dev.to/prashanth1k/commit-to-blog-daily-it-s-smart-and-it-s-stupid-jb1</guid>
      <description>&lt;p&gt;Daily blogging by itself is not a bad thing.&lt;/p&gt;

&lt;p&gt;I changed tracks a year back to get back to development after a million years of doing something else. I thought through the idea of blogging daily, what I was going to write about, and how that would pan out through days and months.&lt;/p&gt;

&lt;p&gt;The premise was simple - learn something, and record that for yourself. The world may benefit from it if it chooses to.&lt;/p&gt;

&lt;p&gt;The idea worked out well at the beginning. I started a new blog at &lt;a href="https://techformist.com"&gt;techformist.com&lt;/a&gt;, and was fairly regular (if not daily).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Thanks to my tech background, I had a few things that I could write about from the very beginning&lt;/li&gt;
&lt;li&gt;I was learning at a quicker pace than anticipated. So, I was getting “more stuff” all the time&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But, as it is with all things with humans, things slowed down.&lt;/p&gt;

&lt;p&gt;I faced the same challenges that I faced elsewhere - I missed out on stuff that I thought was trivial, I regularly failed to record things that I was doing so that I can recall them for future topics, and caught myself worrying about what would be the next big topic to write about.&lt;/p&gt;

&lt;p&gt;I could see clear challenges in sticking to the schedule. In hindsight, I should have known better - especially with my “experience” of blogging since a decade on wide range of topics incl. internet marketing, CRM, gardening, humour and more.&lt;/p&gt;

&lt;p&gt;But, what was different this time was my stupid determination to see it through. I took a vow to continue with the daily blog for an year (target: 2019-10-15), and re-evaluate the state of affairs at that time.&lt;/p&gt;

&lt;p&gt;I took breaks in between running a new company just to stick to schedule. I went completely berserk several times in the last two months to “fill in the gap days”, publish/complete my often incomplete drafts, and fulfil my obsession about this blog being a “daily blog”. I scourged my code for newer tips that I could write about, compared notes with Reddit / Stackoverflow / and even Quora to check what people were asking about, looked at what other daily bloggers were doing, and did everything except visiting a mental health professional.&lt;/p&gt;

&lt;p&gt;I wrote-in the topic for 15-Oct last week, and despite loving what I do - I heaved a sign of relief and have made up my mind to stop the current way.&lt;/p&gt;

&lt;p&gt;Here’s a run down of things that went right and wrong out of 365 days of blogging.&lt;/p&gt;

&lt;h3&gt;
  
  
  What went right?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I forced myself to really “see” many things that were otherwise not paid attention to in a “hectic development schedule”. For example: &lt;a href="https://techformist.com/simpler-curry-notation-javascript/"&gt;currying in Javascript&lt;/a&gt;, &lt;a href="https://techformist.com/reusable-memoization-function-javascript/"&gt;reusable functions for memoization&lt;/a&gt; or &lt;a href="https://techformist.com/map-vs-object-javascript/"&gt;why would someone use maps vis-a-vis an object&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;to an extent - I could hold myself accountable to the wider world to churn out new stuff ( world = those who dared to read the blog). Even if the said stuff meant little to them over the course of time. For example, &lt;a href="https://techformist.com/array-manual-sort-javascript/"&gt;bubble sort&lt;/a&gt;, or &lt;a href="https://techformist.com/fibonacci-series-using-generator-javascript/"&gt;more&lt;/a&gt; &lt;a href="https://techformist.com/memoization-javascript/"&gt;than&lt;/a&gt; a &lt;a href="https://techformist.com/reusable-memoization-function-javascript/"&gt;few&lt;/a&gt; posts about how to generate Fibonacci series.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I proved to myself for the umpteenth time that I could stick to boring things just so to see it completed&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What went wrong?
&lt;/h3&gt;

&lt;p&gt;Technically, nothing. But practically -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Quality suffered at the expense of number of posts. This should not be the case in an ideal world, but I am not a member of one&lt;/li&gt;
&lt;li&gt;Topics tend to focus on solving something small - my whole purpose on the blog seemed to be focused on “satisfying the quota”. This is a wrong approach for learning or for sharing of anything worth sharing. Long-form topics were shunned if I had some catching up to do on the daily blog requirements - and this was (seemingly) all the time&lt;/li&gt;
&lt;li&gt;It is ok to blog for self. But you cannot hold attention of readers on small, seemingly adhoc topics (even though the thread of web development holds everything together). Long-form posts are loved and respected by both readers, and as a consequence, by search engines. People read through at the posts for a longer time, seem to appreciate the deeper coverage a bit more, click-through to browse a few other topics, and possibly subscribe to future updates anticipating similar value&lt;/li&gt;
&lt;li&gt;It is ok to solve a small problem in a post, but very few readers stick on to browse through other topics&lt;/li&gt;
&lt;li&gt;I should have followed up my daily blog with a book, videos or something else. This did not quite happen in the same way that I envisioned it to happen&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of these points are anything new (even for a being like me) but I derive satisfaction in looking back, seeing the bigger picture and to validate, yet again, that the tract of ‘humanity repeating itself’ is intact.&lt;/p&gt;

&lt;h3&gt;
  
  
  What’s in it for you?
&lt;/h3&gt;

&lt;p&gt;Take-aways for anyone interested in the topic -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You will enjoy blogging daily if you are interested in the topic. You will subject yourself to suffering if you hold yourself accountable to it&lt;/li&gt;
&lt;li&gt;Prefer long-form posts and deliver more value within a single post rather than splitting things in multiple posts just for the sake of it&lt;/li&gt;
&lt;li&gt;Daily tips are ok, but don’t be afraid to repeat them at the risk of infuriating your loyal readers. Daily blogs are best run through email if you are looking forward to taking your message to the world&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blog</category>
    </item>
    <item>
      <title>A simpler curry for Javascript</title>
      <dc:creator>Prashanth Krishnamurthy</dc:creator>
      <pubDate>Wed, 25 Sep 2019 00:00:00 +0000</pubDate>
      <link>https://dev.to/prashanth1k/a-simpler-curry-for-javascript-j01</link>
      <guid>https://dev.to/prashanth1k/a-simpler-curry-for-javascript-j01</guid>
      <description>&lt;p&gt;Here's a simpler way to do curry functions in Javascript.&lt;/p&gt;

&lt;p&gt;We have previously seen &lt;a href="https://techformist.com/currying-in-javascript/"&gt;currying in Javascript&lt;/a&gt;. A simple form and application of that concept is demonstrated below -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const addThem = add.curry(2);
const addTotal = addThem(1);
console.log("addTotal: ", addTotal); // 3

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

&lt;/div&gt;



&lt;p&gt;Alternatively, we could avoid an external function or library and &lt;a href="https://techformist.com/curry-using-bind-javascript/"&gt;curry using bindings&lt;/a&gt; ..&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function add(x) {
  return function(y) {
    return y + x;
  };
}

const addEm = add(1);

console.log(addEm(2)); // 3

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

&lt;/div&gt;



&lt;p&gt;But, there is a simpler way to get the same result.&lt;/p&gt;

&lt;p&gt;We just use arrow functions to collect arguments at different times.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const add = x =&amp;gt; y =&amp;gt; x + y;

const addEm = add(1);
console.log(addEm(2)); // 3

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

&lt;/div&gt;



&lt;p&gt;We can make the code more readable with a different notation to do the actual curry -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const add = x =&amp;gt; y =&amp;gt; x + y;
console.log(add(1)(2)); // 3

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

&lt;/div&gt;



&lt;p&gt;Of course, you have to rely back on the previously provided example if you don’t have all arguments in one go.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What is GraphQL and why I should use it?</title>
      <dc:creator>Prashanth Krishnamurthy</dc:creator>
      <pubDate>Wed, 21 Aug 2019 06:30:00 +0000</pubDate>
      <link>https://dev.to/prashanth1k/what-is-graphql-and-why-i-should-use-it-20kn</link>
      <guid>https://dev.to/prashanth1k/what-is-graphql-and-why-i-should-use-it-20kn</guid>
      <description>&lt;p&gt;Why do I use GraphQL? Also, the case for not using GraphQL.&lt;/p&gt;

&lt;p&gt;You must have seen the previous post where I waxed eloquent about &lt;a href="https://techformist.com/not-designing-rest-services"&gt;how I mess up my Rest APIs&lt;/a&gt;. There was no way I would be satisfied doing that to a single technology stack. &lt;/p&gt;

&lt;p&gt;Ergo, GraphQL.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the need for GraphQL?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.google.com/search?q=graphql"&gt;Google GraphQL&lt;/a&gt; and refer &lt;a href="https://graphql.org/learn/"&gt;docs&lt;/a&gt;- there are smarter people with better answers than me.&lt;/p&gt;

&lt;p&gt;But, since the Internet can be a scary place and I love to write about things that I am not an expert in - here's a gist about what I think.&lt;/p&gt;

&lt;p&gt;Back to the story..&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;GraphQL is the SQL for APIs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Before you say .. 'ah.. I now know everything!', read on.&lt;/p&gt;

&lt;p&gt;You see - most of the transactions on the web involve fetching some data or the other.&lt;/p&gt;

&lt;p&gt;Clients need to be authenticated, authorised and then request data for those transactions to happen. Servers, which supply the data, will comply with client requests based on pre-defined rules.&lt;/p&gt;

&lt;p&gt;Rest is an architectural style that allows you to standardize and streamline client-server requests. You can control resources (accounts, contacts etc.) and the operations (GET, STORE etc.).&lt;/p&gt;

&lt;p&gt;So far so good. You may even &lt;em&gt;think&lt;/em&gt; that you reached a Nirvana state with what has been described so far, but imagine what would happen if you start a series of requests -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You: Give me contacts
Server: Here are 100 contacts with 501 fields per contact

You: Give me contacts and activities for each contact
Server: Here are 1000 contacts and 1 million activities per contact

You: Give me contact detail
Server: Here you go - 1000 fields of the contact
You: Give me address for the same contact
Server: Oh God, you again? Here's the address. And, can you please stop this madness?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see such examples in the real world - the problems described are referred as 'over-fetching' (getting more data than I need) and 'under-fetching' (getting less data than I need).&lt;/p&gt;

&lt;p&gt;The properties of over-fetching -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;server fetches more data from database (or may query for related entities that are not always required)&lt;/li&gt;
&lt;li&gt;more data is pushed through the pipe&lt;/li&gt;
&lt;li&gt;client gets more data than required and has to process data to selectively pick and display data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And, those for under-fetching -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;client does not require all data in one-go, requests for related entities or fields&lt;/li&gt;
&lt;li&gt;additional network requests and more needless traffic&lt;/li&gt;
&lt;li&gt;more time to render UI with complete data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The back &amp;amp; forth between server and client frustrates the server - as seen in above conversation, and more importantly, impacts client-side performance.&lt;/p&gt;

&lt;p&gt;The multiple back &amp;amp; forth requests make Rest "chatty".&lt;/p&gt;

&lt;p&gt;Ergo, GraphQL.&lt;/p&gt;

&lt;p&gt;(I assure you - Matrix has very little to do with me using 'ergo' all the time.)&lt;/p&gt;

&lt;h3&gt;
  
  
  But really, why do &lt;em&gt;I&lt;/em&gt; use GraphQL?
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;I&lt;/em&gt; certainly do not use GraphQL because it -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;is the in-thing in web development today&lt;/li&gt;
&lt;li&gt;is revered by everyone who say there is nothing more wonderful&lt;/li&gt;
&lt;li&gt;is typed, and that makes it so magical&lt;/li&gt;
&lt;li&gt;provides a really good looking IDE that makes it so easy to develop the queries&lt;/li&gt;
&lt;li&gt;makes services so easy to code (all it needs is a gesture and all the little thingies arrange themselves in perfect harmony)&lt;/li&gt;
&lt;li&gt;drastically reduces chatty network traffic and improves the speed to 'burn rubber' levels even before ignition is turned on&lt;/li&gt;
&lt;li&gt;uses in-built security rules that makes it so easy to provide role-based authorization&lt;/li&gt;
&lt;li&gt;is loved equally by server and client tech stacks&lt;/li&gt;
&lt;li&gt;specifies a good abstraction layer for databases&lt;/li&gt;
&lt;li&gt;has subscriptions and those are so so amazing&lt;/li&gt;
&lt;li&gt;is developed by Facebook. I happen to adore Zuckerberg&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Or, I may be using GraphQL for a couple of points mentioned above and that is embarrassing to admit (or downright stupid).&lt;/p&gt;

&lt;p&gt;The primary reasons for me to use GraphQL are -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it reduces work on the server-side (surprise, surprise!?). I do not have to write APIs for each and every request, or over-engineer APIs imagining all possible scenarios. Since most of my services are data-heavy, I particularly like the fact that I don't need to maintain a dozen end-points&lt;/li&gt;
&lt;li&gt;development iterations are easier on client. I can make adjustments to client code to fetch more or less data&lt;/li&gt;
&lt;li&gt;pass only the required data b/w client and server&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But, on the other hand -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GraphQL makes it harder to code server-side services (that is just me, not the fault of GraphQL per se).&lt;/li&gt;
&lt;li&gt;I also find it harder to control the queries that clients request while they snicker in the background (the developers of the said client, not client-users. Since I am the only developer in many of my applications, I snicker to myself about myself. I need help!).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I find it easier to just enable standard Rest pattern to start with (scaffolded most of the time). Then, I start enabling GraphQL services for specific transactions and go from there.&lt;/p&gt;

&lt;h3&gt;
  
  
  Err.. what are you even talking about?
&lt;/h3&gt;

&lt;p&gt;Let's see a few examples.&lt;/p&gt;

&lt;p&gt;If I need to get a specific contact, I would do the following transaction in REST -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET https://api.com/contact

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

&lt;/div&gt;



&lt;p&gt;The response will be -&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="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;contacts&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="na"&gt;planet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;earth&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Rama&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;planet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mercury&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Kris&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;planet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mars&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Joe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;63&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;I can do the following in GraphQL and send it as a POST request to server -&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;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;contacts&lt;/span&gt;&lt;span class="p"&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="s2"&gt;"Rama"&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="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;age&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;The response will be like so -&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="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;contacts&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Rama&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;42&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;The responses in the two transactions speak for themselves!&lt;/p&gt;

&lt;h3&gt;
  
  
  What are GraphQL operations? And, why should I care?
&lt;/h3&gt;

&lt;p&gt;No matter what we do in the client-server world - we are trying to do one simple thing -&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Share data and business logic b/w server and client&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One can query, insert, update or delete data and can initiate those transactions from client. This can either happen -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;with the server not caring about the "state" of the client. i.e., client sends request (with authentication incl. as part of request if required), and server answers the call&lt;/li&gt;
&lt;li&gt;server keeps client interests in mind, has an open channel with the client, and keeps track of data so that clients get changes as they happen&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;GraphQL builds a layer on top of a database to assist you to transmit data in both cases.&lt;/p&gt;

&lt;h5&gt;
  
  
  Query
&lt;/h5&gt;

&lt;p&gt;GraphQL queries help you to fetch only the records and attributes you need - we have seen examples earlier.&lt;/p&gt;

&lt;p&gt;You can also include different entities (think 'tables' as an analogy) in the request. Use GraphQL to fetch records with specified relationships, rather than making separate requests for distinct entities.&lt;/p&gt;

&lt;h5&gt;
  
  
  Mutation
&lt;/h5&gt;

&lt;p&gt;GraphQL mutations are used to insert/change data.&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;mutation&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;createContact&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;addContact&lt;/span&gt;&lt;span class="p"&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="s2"&gt;"Joe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&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="n"&gt;id&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;The above query provides instruction to use a mutation called &lt;code&gt;createContact&lt;/code&gt; that in turn uses &lt;code&gt;addContact&lt;/code&gt; to add a contact record with name &lt;code&gt;Joe&lt;/code&gt; and age &lt;code&gt;100&lt;/code&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  Subscription
&lt;/h5&gt;

&lt;p&gt;Subscriptions establish a channel between server and client. Clients can subscribe to record updates and get notified (through a simple notification, or by actual 'push' of the data from server) whenever there are changes.&lt;/p&gt;

&lt;p&gt;Subscriptions use 'web sockets' under the hood. This is a battle-tested piece of technology that enables real-time data updates to client.&lt;/p&gt;

&lt;p&gt;For example - clients can use the below subscription to get the list of contacts who won the lottery.&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;subscription&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;listenWonLottery&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;wonLottery&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;name&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;deals&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;Let's see the flow -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clients subscribe to contacts&lt;/li&gt;
&lt;li&gt;One or more of the contacts get updated in the database when they win lottery&lt;/li&gt;
&lt;li&gt;On database update, a notification gets triggered to clients&lt;/li&gt;
&lt;li&gt;The notification contains contact's name and deals associated with contact&lt;/li&gt;
&lt;li&gt;Client can thereon show a popup with contact name and show flying balloons for effect&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What are the different components required to implement GraphQL?
&lt;/h3&gt;

&lt;p&gt;GraphQL is just the language for API and runtime for executing them queries. It is not hardwired to database and does not specify how the database operations need to be executed.&lt;/p&gt;

&lt;p&gt;The different components that implement GraphQL stack are below. These components are not part of GraphQL specifications but are just part of the stack that support transactions using GraphQL.&lt;/p&gt;

&lt;h5&gt;
  
  
  Server
&lt;/h5&gt;

&lt;p&gt;The implementation/tech stack decides how GraphQL is incorporated in the transaction. Server receives GraphQL requests from clients, establishes connection to database, converts graph queries to a language understood by database, fetches results and sends the responses back to clients.&lt;/p&gt;

&lt;p&gt;A server may also include the functions expected from a "normal" server -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;apply business logic to data&lt;/li&gt;
&lt;li&gt;listen to supported types of requests on specified network ports&lt;/li&gt;
&lt;li&gt;takes care of all the supporting infrastructure required to serve requests to clients.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Database
&lt;/h5&gt;

&lt;p&gt;Stores data and maintains atomicity, consistency etc. etc. for data. It is a glorified file system that supports individual transactions and does not mess up the data just because the network went kaput, or your client decided to play a game.&lt;/p&gt;

&lt;h5&gt;
  
  
  Client
&lt;/h5&gt;

&lt;p&gt;Can be a browser, mobile app or anything that requests data from server and consumes server response to do "something". We create GraphQL queries, mutations etc. and send them over in a simple POST request.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the terms that I should be familiar about?
&lt;/h3&gt;

&lt;h5&gt;
  
  
  Schema
&lt;/h5&gt;

&lt;p&gt;A schema is the building block of GraphQL. It is described using a language that we can understand - it can be any language, but a simple option aptly named "Schema Definition Language" is used in the standard implementation.&lt;/p&gt;

&lt;p&gt;Consider the below example -&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;Contact&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;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="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;deal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Deal&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="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Deal&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;description&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="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;value&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="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;The schema definition helps a client-side developer to see and understand the relationships b/w data entities, and thereon construct a GraphQL query.&lt;/p&gt;

&lt;h5&gt;
  
  
  Resolvers
&lt;/h5&gt;

&lt;p&gt;A resolver is a function that returns data in the shape specified by schema.&lt;/p&gt;

&lt;p&gt;For e.g. -&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;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="nx"&gt;contact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&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="nx"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;contact&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;contact&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="nx"&gt;deals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&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="nx"&gt;deals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;deal&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;deal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&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="na"&gt;Contact&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;deals&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;contact&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&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;deals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;deal&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;deal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;contactId&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;contact&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&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;We use a resolver to write queries, mutations and subscriptions.&lt;/p&gt;

&lt;h5&gt;
  
  
  Object type / fields
&lt;/h5&gt;

&lt;p&gt;In the GraphQL query outlined above -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Object type is 'Contact' and 'Deal'&lt;/li&gt;
&lt;li&gt;Fields are &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;description&lt;/code&gt;, and &lt;code&gt;value&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  This is so cool that I slept through the article. Give it to me straight - should I use GraphQL?
&lt;/h3&gt;

&lt;p&gt;Not everywhere.&lt;/p&gt;

&lt;p&gt;Use GraphQL when you need to fetch a lot of data having varying shapes / many relationships. Use GraphQL to simplify the data passed between client and server.&lt;/p&gt;

&lt;p&gt;At the same time -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Remember that plain Rest API implementations are simpler&lt;/li&gt;
&lt;li&gt;Even in data-heavy applications, I do not see a big advantage of applying GraphQL everywhere (except architectural uniformity/ standardization, maybe). For e.g. if you have narrow relationships between entities that do not require related data views all the time&lt;/li&gt;
&lt;li&gt;Keep track of how clients use GraphQL - crazy queries can lead to performance issues&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Why do I find Rest services simpler?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Endpoint setup is simple on the server. Expose an API or two, and use an ORM to fetch/update data in one or two steps - no sight of fields and related entities anywhere unless you want to deal with them&lt;/li&gt;
&lt;li&gt;In addition to the previous point, or supplementing it, is the fact that the tooling is amazing - the technology is so old and supported so well that most of the time it just requires a couple of clicks (or lines of code) to fully set up&lt;/li&gt;
&lt;li&gt;I control queries in the back-end - easier control on who accesses the data and how. I also find it easier to solve potential performance issues since I control filters and sort on the server&lt;/li&gt;
&lt;li&gt;But all said and done, I may be finding Rest easier since I have spent so much time with it :)&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Ok, I am in. Where should I start?
&lt;/h3&gt;

&lt;p&gt;I find the following technology stacks easy to follow and useful to learn for the long run. The recommendations are skewed towards Vue since I use Vue all the time and strongly believe that Vue is easier on beginners.&lt;/p&gt;

&lt;h5&gt;
  
  
  Enable GraphQL server-side
&lt;/h5&gt;

&lt;p&gt;It is a good idea to create a server on your own and see GraphQL flow in the back-end for real.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;Recommended&lt;/th&gt;
&lt;th&gt;Remarks&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;I know SQL and understand DBs&lt;/td&gt;
&lt;td&gt;&lt;a href="https://www.graphile.org/postgraphile/"&gt;PostGraphile&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Refer &lt;a href="https://techformist.com/spin-up-your-own-local-graphql-server-within-15-min/"&gt;this&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;I want to learn more of serverless&lt;/td&gt;
&lt;td&gt;&lt;a href="https://aws.amazon.com/appsync/"&gt;AppSync&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Sign up for 1-year limited free servers on Amazon AppSync&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;I want to learn GraphQL using a CMS&lt;/td&gt;
&lt;td&gt;&lt;a href="https://strapi.io/"&gt;StrapiJS&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;In beta, but good for production&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;I want to experiment with static sites + GraphQL&lt;/td&gt;
&lt;td&gt;&lt;a href="https://gridsome.org/"&gt;Gridsome&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;New, but promising.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;I know PHP&lt;/td&gt;
&lt;td&gt;Laravel + &lt;a href="https://lighthouse-php.com/"&gt;Lighthouse&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;I am looking forward to a long-term relationship&lt;/td&gt;
&lt;td&gt;&lt;a href="https://nestjs.com/"&gt;NestJS&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Good server capabilities + good GraphQL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;I am a master&lt;/td&gt;
&lt;td&gt;Guide me towards enlightenment, maybe&lt;/td&gt;
&lt;td&gt;What are you even doing here?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h5&gt;
  
  
  Use GraphQL on the client
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://vuejs.org"&gt;Vue&lt;/a&gt; + &lt;a href="https://github.com/Akryum/vue-apollo"&gt;Vue-Apollo&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://svelte.dev/"&gt;Svelte&lt;/a&gt; + &lt;a href="https://github.com/apollographql/apollo-client/tree/master/packages/apollo-boost"&gt;Apollo&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also see: &lt;a href="https://techformist.com/create-a-simple-to-do-app-using-svelte-and-graphql/"&gt;create a simple to-do with Svelte + GraphQL&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Finis
&lt;/h3&gt;

&lt;p&gt;It ends here :)&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>graphql</category>
    </item>
    <item>
      <title>Spin up your own local GraphQL server within 15 min</title>
      <dc:creator>Prashanth Krishnamurthy</dc:creator>
      <pubDate>Thu, 21 Feb 2019 15:30:00 +0000</pubDate>
      <link>https://dev.to/prashanth1k/spin-up-your-own-local-graphql-server-within-15-min-16nc</link>
      <guid>https://dev.to/prashanth1k/spin-up-your-own-local-graphql-server-within-15-min-16nc</guid>
      <description>&lt;p&gt;Create your own GraphQL APIs in 15 min flat using a Postgres database and a bit of help from PostGraphile. No GraphQL server configuration needed.&lt;/p&gt;

&lt;p&gt;No frontend beginner developer ever said - "I want to play around with servers to understand their internals byheart before I venture forth with my beautiful Vue application".&lt;/p&gt;

&lt;p&gt;If you are building on REST APIs, you have public services like &lt;a href="https://jsonplaceholder.typicode.com/"&gt;JSONPlaceholder&lt;/a&gt;. These services provide quick access to much-loved sample APIs for to-do, posts, users etc.&lt;/p&gt;

&lt;p&gt;There are not a lot of choices if you are building on GraphQL. There have been efforts towards providing such an API in the past but none last long. The solution - create them locally.&lt;/p&gt;

&lt;p&gt;Local GraphQL can be cumbersome.&lt;/p&gt;

&lt;p&gt;When you start, one may be left wondering on Express + GraphQL + a bit of configuration + write more than few lines of code to get started to serve any new API. There are tools like &lt;a href="https://github.com/marmelab/json-graphql-server"&gt;json-graphql-server&lt;/a&gt; that claim to speed up this process. However, they are not kept up to date and seemingly are not meant for Windows(?).&lt;/p&gt;

&lt;p&gt;So, I did the next logical thing that was easy and quick. Create an environment of your own using &lt;a href="https://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; and &lt;a href="https://www.graphile.org/postgraphile/"&gt;PostGraphile&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Initial Setup
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.postgresql.org/download/"&gt;Download and install PostgreSQL&lt;/a&gt;. &lt;br&gt;Alternatively use &lt;a href="https://laragon.org/download/"&gt;Laragon with Postgres&lt;/a&gt; - it is a really good control centre for local development. &lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open pgAdmin - the DB admin application for Postgres. Use an existing database or create a new one. Right-click on Schema &amp;gt; Tables and click on 'New Table'. I will assume that you will use a database called 'test'. Create a table called 'todo'.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P4FDqOXt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/r1zgwqkey67dq4226gnd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4FDqOXt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/r1zgwqkey67dq4226gnd.png" alt="postgres-create-table"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a few columns&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3DAseB2b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/vct03eyk1haeei1ksgb6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3DAseB2b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/vct03eyk1haeei1ksgb6.png" alt="pgadmin-create-table-columns"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start your very own GraphQL server. The server uses port 5000 by default, but we will change it to 5050 for the heck of it (also because 5000 is used by a few other front-end apps)&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   npx postgraphile -c test --watch -p 5050
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--__UO7f76--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/x36h4bmkwlb2jjk3pvb7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--__UO7f76--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/x36h4bmkwlb2jjk3pvb7.png" alt="postgraphile-server-start"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Start playing around
&lt;/h3&gt;

&lt;p&gt;Go to [&lt;a href="http://localhost:5050/graphiql"&gt;http://localhost:5050/graphiql&lt;/a&gt;]. Copy/paste the GraphQL statements to perform different operations.&lt;/p&gt;

&lt;h5&gt;
  
  
  Query data
&lt;/h5&gt;

&lt;p&gt;Query for data. Of course, you will not find anything at this time.&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;allTodos&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;nodes&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="w"&gt;
      &lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="n"&gt;done&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;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;The output will be -&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="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;data&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&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;allTodos&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&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;nodes&lt;/span&gt;&lt;span class="dl"&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="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;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JbKrv6bn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kheuy9t4ij6rieeycqe1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JbKrv6bn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kheuy9t4ij6rieeycqe1.png" alt="graphiql-graphql-server-simple"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Insert data
&lt;/h5&gt;

&lt;p&gt;Insert 'to-do' data in your database.&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;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;createTodo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&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="n"&gt;todo&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="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Create GraphQL server"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;done&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&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;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;todo&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="w"&gt;
      &lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="n"&gt;done&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;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;This statement will create a single to-do, query back &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;title&lt;/code&gt;, &amp;amp; &lt;code&gt;done&lt;/code&gt; fields, and display them at the right-hand side of the screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VaUFF8H5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/46zxspfw0x8a1qv7phuq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VaUFF8H5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/46zxspfw0x8a1qv7phuq.png" alt="graphiql-graphql-mutation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Output -&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="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;data&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&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;createTodo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&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;todo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&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;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;title&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;Create GraphQL server&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;done&lt;/span&gt;&lt;span class="dl"&gt;"&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="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;You can repeat the &lt;code&gt;query&lt;/code&gt; operation and find that it can display data too!&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure additional APIs
&lt;/h3&gt;

&lt;p&gt;By now you have a full-fledged server that is serving to-dos. You can add filters, do magic on inserts/updates using functions, and eventually find that the world is the limit.&lt;/p&gt;

&lt;p&gt;But, what about additional APIs? Similar to to-dos, you can start creating entities and find them available to your GraphQL without any additional effort. That is the magic of PostGraphile.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why use this setup for local GraphQL environment?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Quicker setup. Type in a few commands + configure DB table - and you are done&lt;/li&gt;
&lt;li&gt;Minimal effort to setup new APIs - you are not limited to standard APIs but can go all wild&lt;/li&gt;
&lt;li&gt;You can take this to your production environment too. I have used Postgraphile for projects and it rocks!&lt;/li&gt;
&lt;li&gt;PostGraphile uses your friendly, neighbourhood Javascript. So we are right at home&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  You say?
&lt;/h3&gt;

&lt;p&gt;What do you say about this folks? Super..? Stupid? Somewhere in between? &lt;br&gt;
Or, simply "what am I doing on this planet when people like this exist"..?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Originally published at &lt;a href="https://techformist.com/spin-up-your-own-local-graphql-server-within-15-min/"&gt;https://techformist.com/spin-up-your-own-local-graphql-server-within-15-min/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>beginners</category>
      <category>graphql</category>
      <category>postgraphile</category>
    </item>
  </channel>
</rss>
