<?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: Vikram Rangnekar</title>
    <description>The latest articles on DEV Community by Vikram Rangnekar (@dosco).</description>
    <link>https://dev.to/dosco</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%2F565293%2F27ebb494-3c53-4698-bebd-365de1401372.jpg</url>
      <title>DEV Community: Vikram Rangnekar</title>
      <link>https://dev.to/dosco</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dosco"/>
    <language>en</language>
    <item>
      <title>Build High Performance GraphQL APIs in 5 minutes with GraphJin</title>
      <dc:creator>Vikram Rangnekar</dc:creator>
      <pubDate>Thu, 04 Feb 2021 16:31:15 +0000</pubDate>
      <link>https://dev.to/dosco/build-high-performance-graphql-apis-in-5-minutes-with-graphjin-261o</link>
      <guid>https://dev.to/dosco/build-high-performance-graphql-apis-in-5-minutes-with-graphjin-261o</guid>
      <description>&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs7ho72yuiuofoqa7rfkf.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs7ho72yuiuofoqa7rfkf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What if I told you there was an open source GraphQL backend that automatically learned the structure of your database and allowed you to instantly start querying it with GraphQL. No code or no configs it just works out of the box. &lt;/p&gt;

&lt;p&gt;While this sounds unreal - it exists. GraphJin is an instant GraphQL to SQL compiler that converts your GraphQL query into an efficient and fast SQL query. GraphJin is written in Go and can be used as a standalone service or a library within your own app. It works with Postgres, Mysql and the Distributed Yugabyte and CockroackDB databases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install GraphJin
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go get github.com/dosco/graphjin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You need &lt;a href="https://golang.org/doc/install" rel="noopener noreferrer"&gt;Go installed&lt;/a&gt; on your system. The above command will download, compile and install GraphJin into your &lt;code&gt;GOPATH&lt;/code&gt; which is usually &lt;code&gt;~/go/bin&lt;/code&gt; and should be added to your path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a GraphJin App
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;graphjin new blog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INF created 'blog'
INF created 'blog/Dockerfile'
INF created 'blog/docker-compose.yml'
INF created 'blog/cloudbuild.yaml'
INF created 'blog/config'
INF created 'blog/config/dev.yml'
INF created 'blog/config/prod.yml'
INF created 'blog/config/seed.js'
INF created 'blog/config/migrations'
INF created 'blog/config/migrations/0_init.sql'
INF app 'blog' initialized
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The newly created app will be in the &lt;code&gt;blog&lt;/code&gt; folder and will contain a docker environment, config files and database migration files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup Your Database
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose run api db:setup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We use &lt;a href="https://docs.docker.com/get-docker/" rel="noopener noreferrer"&gt;Docker Compose&lt;/a&gt; which is a nice way to run your entire backend in Docker and not have to clutter your machine. This above command will use &lt;code&gt;docker-compose&lt;/code&gt; to start a &lt;code&gt;Postgres&lt;/code&gt; database and &lt;code&gt;GraphJin&lt;/code&gt; using the &lt;code&gt;config/dev.yml&lt;/code&gt; config file.&lt;/p&gt;

&lt;p&gt;It will then run the &lt;code&gt;db:setup&lt;/code&gt; GraphJin command which will create the &lt;code&gt;blog_development&lt;/code&gt; database and create the tables defined in the &lt;code&gt;config/migrations/0_init.sql&lt;/code&gt; database migration script. It will then run &lt;code&gt;seed.js&lt;/code&gt; the seeding script to add fake data to your database to help you with development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start Your App
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose up
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;up&lt;/code&gt; command will also run the database but this time it will run Graphjin with the &lt;code&gt;serv&lt;/code&gt; command which will start your GraphQL API backend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try some GraphQL
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;query {
  users {
    id
    email
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open a browser and visit &lt;a href="http://localhost:8080" rel="noopener noreferrer"&gt;http://localhost:8080&lt;/a&gt;. You'll be presented with the GraphJin web ui. You can craft and test your GraphQL queries here.&lt;/p&gt;

&lt;h3&gt;
  
  
  Some more details
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Security
&lt;/h4&gt;

&lt;p&gt;In development mode all named queries &lt;code&gt;query getUser { user { id } }&lt;/code&gt; (queries with a name eg: getUser) are saved into an allow list file and in production mode only those queries are allowed to run. This makes GraphJin very fast and secure since no one can send different queries to your API and expect to get any data that you don't want to expose. Also in production mode queries are compiled to database prepared statements which makes then extremely fast.&lt;/p&gt;

&lt;h4&gt;
  
  
  Frontend development
&lt;/h4&gt;

&lt;p&gt;GraphJin works fine with all GraphQL client libraries like &lt;code&gt;Apollo&lt;/code&gt; and &lt;code&gt;URQL&lt;/code&gt;. Just use named queries when building your app they are automatically saved (or updated) as your app evolves. So when deployed into production your allow list is packaged along.&lt;/p&gt;

&lt;h4&gt;
  
  
  Who uses GraphJin
&lt;/h4&gt;

&lt;p&gt;GraphJin is fully open source Apache Licensed project. It has an active and growing community, great documentation and a clean codebase with great test coverage using integration tests.&lt;/p&gt;

&lt;p&gt;GraphJin is being used by many startups saving them months of development time. For example the popular &lt;a href="https://42papers.com" rel="noopener noreferrer"&gt;42papers.com&lt;/a&gt; platform to discover top trending CS/ML and AI papers uses the standalone GraphJin service.&lt;/p&gt;

&lt;h4&gt;
  
  
  Save you time and money
&lt;/h4&gt;

&lt;p&gt;Developing REST APIs to create, update, delete and fetch data from your database is a tedious job also as your UI evolves those APIs have to be maintained and updated. This all takes weeks to months of relatively boring work and can be a vector to introduce security holes in your app. &lt;/p&gt;

&lt;p&gt;With GraphJin all this work goes away instantly. The SQL queries GraphJin generates are lighting fast and your web developers now has to power to create the query he needs while building the UI. It frees you up to focus on the interesting parts of your app. Also GraphJin starts up in milliseconds so it works great on severless scale to zero platforms like Google App Engine, Google CloudRun, AWS Fargate, Azure Container Service. It's tiny, fast and feature packed give it a try and I'm happy to help so feel free to reach out on th comments or my twitter &lt;a href="https://twitter.com/dosco" rel="noopener noreferrer"&gt;@dosco&lt;/a&gt; &lt;/p&gt;

</description>
      <category>graphql</category>
      <category>postgres</category>
      <category>mysql</category>
      <category>serverless</category>
    </item>
    <item>
      <title>REST vs GraphQL - Building Startups in 2021</title>
      <dc:creator>Vikram Rangnekar</dc:creator>
      <pubDate>Tue, 26 Jan 2021 15:04:16 +0000</pubDate>
      <link>https://dev.to/dosco/rest-vs-graphql-building-startups-in-2021-3k73</link>
      <guid>https://dev.to/dosco/rest-vs-graphql-building-startups-in-2021-3k73</guid>
      <description>&lt;p&gt;I was an engineer at Linkedin from 2010 and had a chance to see and help its tech stack evolve to match the growing engineering challenges of a fast growing web product. I also spent several years building my own startup Socialwok which was a Techrunch50 winner. I'm currently building an automagical &lt;code&gt;GraphQL to SQL&lt;/code&gt; compiler called &lt;a href="https://github.com/dosco/graphjin"&gt;GraphJin&lt;/a&gt; and a popular community &lt;a href="https://42papers.com"&gt;42papers.com&lt;/a&gt; around top trending research papers in CS/ML/AI. Over the years I've built many products with various languages and frameworks but until now mostly with REST APIs.&lt;/p&gt;

&lt;p&gt;I have a love-hate relationship with REST APIs. Having spent years consuming APIs from building startups to helping move Linkedin to EmberJS and with various apps in &lt;code&gt;React&lt;/code&gt; and &lt;code&gt;Vue&lt;/code&gt;. And as a producer of APIs external and internal APIs as part of Linkedin's Ads Engineering and other teams. The key takeaway I have from all this experience is if a technology is slowing you down then it's the wrong choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  REST
&lt;/h2&gt;

&lt;p&gt;In the REST world building an API first required you to name it and think up the URL structure. I found that even these simple things are really hard since neither quite fit. Should it be &lt;code&gt;/users/3/products&lt;/code&gt;, &lt;code&gt;/products?user_ids=3,4,5&lt;/code&gt; or something entirely different &lt;code&gt;/products_page?q=user:3&lt;/code&gt;. Does it make sense to use &lt;code&gt;PUT&lt;/code&gt;, &lt;code&gt;POST&lt;/code&gt; or &lt;code&gt;PATCH&lt;/code&gt;, etc. While REST and GraphQL are both just de-facto standards with REST even the basics are over the place.&lt;/p&gt;

&lt;p&gt;Most of REST world focuses on building resource specific APIs while in the real world your needs are more view or action specific. This is also why backend rendering like in Rails makes so much sense as opposed to firing tens of API calls.&lt;/p&gt;

&lt;p&gt;Let me tell you a story that you'll find familiar. Say you're working at your job and the product team decides that a profile image and a full-name should be added to each comment on the page. The current API only returns the first name so the PM adds a ticket on the backend team. The backend developer now has to change the &lt;code&gt;SQL&lt;/code&gt; and the &lt;code&gt;JSON&lt;/code&gt; structure to return these new fields this takes a day or more blocking the React, Android and IOS developer. And with smaller teams it turns into a massive context-switch into the backend stack to make this change. In short it's not great we wasting time, money and productivity. And This happens over and over again.&lt;/p&gt;

&lt;p&gt;So what's good about REST? Well its popular cause it was simple to start with and it native to browsers. All the good-ness of &lt;code&gt;ETags&lt;/code&gt;, &lt;code&gt;Cache-Control&lt;/code&gt;, etc comes out of the box. you can use &lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;POST&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;. All you need is an HTTP client.&lt;/p&gt;

&lt;p&gt;What seems simple to start with has an added cost that you pay as long as you continue to use it. I've even sat in meetings to decide the url path of an API. I can bet like me you'd like that hour of your life back. REST APIs are too limiting and too restrictive for the fast and data rich applications of today. &lt;/p&gt;

&lt;p&gt;But REST is not all bad there are several use-cases where REST continues to be the best choice. For &lt;code&gt;OAuth&lt;/code&gt; based auth flows, file upload or download endpoints, sharable links and web hooks to name a few.&lt;/p&gt;

&lt;h2&gt;
  
  
  GraphQL
&lt;/h2&gt;

&lt;p&gt;Life has shown me that the best products are built by teams that value the developers experience as much as the customers experience. Technology that allows your team the freedom to move fast will provide you the highest return on investment. This is exactly why &lt;code&gt;Github&lt;/code&gt;, &lt;code&gt;Shopify&lt;/code&gt;, &lt;code&gt;Twitch&lt;/code&gt;, etc were all built on &lt;code&gt;Rails&lt;/code&gt;. A complex stack that came with all common requirements included and minimizes context switching. It allowed the developer to do focused work faster.&lt;/p&gt;

&lt;p&gt;Yes, the infrastructure required to use GraphQL is more than REST but it gives more back by helping developers to do more focused work faster.&lt;/p&gt;

&lt;p&gt;Frontends today, mobile or web are increasingly complex and designed to provide rich experiences to your customers. It's a highly specialized skill. A React developer has to juggle the state management, user-experience, javascript tooling and the same with Android or IOS developers. The last thing you want is for him to be blocked or have to also fix APIs.&lt;/p&gt;

&lt;p&gt;GraphQL gives power back to the person building the customer facing apps. He can query for the data he needs when he needs it. He does not have to remember complex REST APIs semantics and or if to use a &lt;code&gt;POST&lt;/code&gt;, &lt;code&gt;PUT&lt;/code&gt;, &lt;code&gt;GET&lt;/code&gt; or whatever. He just writes out his query in GraphQL and the data just shows up. It's simple. &lt;/p&gt;

&lt;p&gt;Almost 90% of all apps require fetching complex related data to render page views. GraphQL allows your frontend devs to fetch all the data they need in a single query without waiting on anyone else. This results in faster apps for your customers and to iterate on for your devs.&lt;/p&gt;

&lt;p&gt;GraphQL has many more useful capabilities for example subscriptions. Once your initial view is rendered you can then subscribe to the same view query to get instant updates over web-sockets. This is much more efficient and nicer than the long polling that you'd have to do with REST.&lt;/p&gt;

&lt;p&gt;People often bring up caching as a weak point of GraphQL. And I'll agree somewhat since it's not easy to leverage browser caching with &lt;code&gt;POST&lt;/code&gt;GraphQL endpoints. However GraphQL client libraries like &lt;code&gt;Apollo&lt;/code&gt; and &lt;code&gt;URQL&lt;/code&gt; have come far and have quite sophisticated caching capabilities that even go further than what browser provide REST APIs. Additionally GraphQL now has features like automatic persisted queries or &lt;code&gt;APQ&lt;/code&gt; that allow you to use GraphQL over REST APIs leveraging that browser caching you wanted.&lt;/p&gt;

&lt;p&gt;In short GraphQL is a querying language that when done right can help your team build data rich modern app experiences quicker leaving you more room to iterate towards a product your customers love.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;You'll probably need both. REST APIs will continue to play their part in your stack and GraphQL will take on the job of the primary driver for fetching and changing the data that your app deals with.&lt;/p&gt;

&lt;p&gt;Getting started with GraphQL is very easy there are several open source options out there all of which are pretty solid. While I'm a little biased I'll recommend checking out &lt;a href="https://github.com/dosco/graphjin"&gt;GraphJin&lt;/a&gt; a GraphQL backend in GO that will save you countless hours. Just point GraphJin at your Postgres or MySQL database and start writing your GraphQL queries, it will automagically convert them into an efficient SQL query and fetch the data needed from your database. It also learns the schema and relationships in your database on its own so no config or code required.&lt;/p&gt;

&lt;p&gt;I'd love to hear what your thoughts are on this debate. Would you pick GraphQL and if not then why? And if you are using GraphQL currently then what is your stack made up of?&lt;/p&gt;

&lt;p&gt;You can find me at &lt;a href="//twitter.com/dosco"&gt;twitter.com/dosco&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>postgres</category>
      <category>mysql</category>
      <category>api</category>
    </item>
  </channel>
</rss>
