<?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: Amrit</title>
    <description>The latest articles on Forem by Amrit (@amritprabhat).</description>
    <link>https://forem.com/amritprabhat</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%2F1236579%2F3cb55dd8-a949-401b-9932-2188fe85c236.jpg</url>
      <title>Forem: Amrit</title>
      <link>https://forem.com/amritprabhat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/amritprabhat"/>
    <language>en</language>
    <item>
      <title>Unravelling GraphQL: Your Passport to Smarter APIs</title>
      <dc:creator>Amrit</dc:creator>
      <pubDate>Tue, 19 Dec 2023 08:55:42 +0000</pubDate>
      <link>https://forem.com/epam_india_python/unravelling-graphql-your-passport-to-smarter-apis-3hhp</link>
      <guid>https://forem.com/epam_india_python/unravelling-graphql-your-passport-to-smarter-apis-3hhp</guid>
      <description>&lt;p&gt;Hey there fellow testers! Today, let's embark on an exciting journey into the world of GraphQL. If you've ever found yourself drowning in a sea of unnecessary data or wrestling with multiple API calls, GraphQL might just be the superhero you've been waiting for. Buckle up, and let's demystify the magic of GraphQL together!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Let's Get Acquainted with GraphQL
&lt;/h2&gt;

&lt;p&gt;So, what's this GraphQL thing anyway? Picture it as a language that allows your front end to have a conversation with the back end but without awkward pauses or unnecessary details. It's like ordering a customized pizza instead of getting a pre-made one with toppings you don't want.&lt;br&gt;
GraphQL is a query language for API's. We can query the data by writing the GraphQL.&lt;br&gt;
So we can query the data by writing GraphQL. GraphQL is a  query language through which those queries we can read the data or we can update the data we can read the data in the servers so GraphQL is a query language especially for APIs and keep in mind there is no relation with SQL. &lt;br&gt;
SQL is a completely different structure query language and is a database-related language and GraphQL is purely related to API so it is a query language for retrieving the data from API.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The Big Three: Queries, Mutations, Subscriptions
&lt;/h2&gt;

&lt;p&gt;In GraphQL, we have three superheroes – Queries, Mutations, and Subscriptions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3fPdee7E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r10g5kmkqzxucbdrfqjc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3fPdee7E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r10g5kmkqzxucbdrfqjc.png" alt="Image description" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Queries:  Think of them as questions you ask the server to get specific information. 
And the cool part? It's all defined in a schema, a bit like creating a map for your conversation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TNpsHA_u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/skqq9doh02066q5l15rr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TNpsHA_u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/skqq9doh02066q5l15rr.png" alt="Image description" width="800" height="274"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hasura.io/learn/graphql/graphiql"&gt;Playground:  GraphiQL Online with Headers | Built by Hasura&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rL4kJ523--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7r7mcz6llw2q3wjd1uai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rL4kJ523--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7r7mcz6llw2q3wjd1uai.png" alt="Image description" width="800" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using limit function:  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k1rG0eTB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5hvww0u4wfe8zzkc6gaf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k1rG0eTB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5hvww0u4wfe8zzkc6gaf.png" alt="Image description" width="800" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using the where and like function:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xCEU7KvF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/761i13eyg0fehltjan70.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xCEU7KvF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/761i13eyg0fehltjan70.png" alt="Image description" width="800" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Likewise, there could be more functions as we can see in normal databases like SQL give broad insight into sorting and searching the resources from an endpoint.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Mutations:  When you want to change something on the server, like adding a comment or updating a profile picture, mutations come to the rescue.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ukr3cfMJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ab69s2vwhc72spvg6xnz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ukr3cfMJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ab69s2vwhc72spvg6xnz.png" alt="Image description" width="379" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Updating, deletion and then creation will happen through mutation type of queries.&lt;br&gt;
Screenshot from “Hasura” playground  GraphiQL Online with Headers | Built by Hasura for GraphQL&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Subscriptions:  Ever wanted your app to shout, "Hey, something cool just happened!" without you refreshing the page? Subscriptions make real-time updates possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. The Showdown: GraphQL vs REST
&lt;/h2&gt;

&lt;p&gt;Imagine you're ordering food. REST is like ordering from a fixed menu, and you get everything, whether you want it or not. GraphQL, on the other hand, is like telling the chef exactly what you want – no more, no less. No more food analogies, promise!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kYCnDUx4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ncaulzq5f48cxlfyv4sn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kYCnDUx4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ncaulzq5f48cxlfyv4sn.png" alt="Image description" width="800" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Y7aao_D1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ov4dhnejh8c1bo4eepjb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y7aao_D1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ov4dhnejh8c1bo4eepjb.png" alt="Image description" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In REST We have a URL which  contains the endpoint and when you hit the URL we'll get some response from the server and  we will get the resource from the server if you want to get multiple resources we have to  send multiple requests right &lt;br&gt;
Whereas In GraphQL we do not need to send multiple types of requests  with a single request we can get multiple resources  from the server&lt;br&gt;
Instead of making different API calls to different URLs to fetch data, we're making ad-hoc queries to a "single URL endpoint" that returns data based on the query.&lt;/p&gt;

&lt;p&gt;• The "query" you send as data in the POST request has a structure and a syntax. This "language" is called GraphQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Let's Get Our Hands Dirty
&lt;/h2&gt;

&lt;p&gt;Setting Up the GraphQL Party&lt;br&gt;
Getting started is a breeze. We'll set up our own GraphQL server – the VIP section of data fetching.&lt;br&gt;
Or we can use GraphiQL Online with Headers | Built by Hasura let me show you how exactly GraphQL works so let me just go to this URL asura.io , and here this is a website Hasura, this is a very popular website they provide so many demo type of APIs and if you want to use their APIs open APIs we need to First login into this and then we will able to access that access the APIs.&lt;br&gt;
Hitting the Dance Floor with Queries and Mutations&lt;/p&gt;

&lt;p&gt;Using POSTMAN: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Setup the authorisation copy it from Hasura&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bHi3OBOZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/od14c52zgk118orr3o7c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bHi3OBOZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/od14c52zgk118orr3o7c.png" alt="Image description" width="800" height="22"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; New POST request paste the URL from Hasura &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IG21bTJ---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bgozwnqcf7smk48bhayo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IG21bTJ---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bgozwnqcf7smk48bhayo.png" alt="Image description" width="572" height="64"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Select the radio button GraphQL (as of now no variables are required to leave it empty)
Write the desired Query and click Send&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qm7Gu0O_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5tmhpzap5ziccnry6osf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qm7Gu0O_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5tmhpzap5ziccnry6osf.png" alt="Image description" width="800" height="227"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; You will get the response in the form of JSON &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nROExl3X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n1r1b9bzvisafqb3mfzp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nROExl3X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n1r1b9bzvisafqb3mfzp.png" alt="Image description" width="800" height="449"&gt;&lt;/a&gt;&lt;br&gt;
Passing variables dynamically&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VF6D6QWK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/onftf2zw5c23on9mukwe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VF6D6QWK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/onftf2zw5c23on9mukwe.png" alt="Image description" width="800" height="395"&gt;&lt;/a&gt;&lt;br&gt;
Here few hard code arguments are being passed like limit: 2 we can make that a variable to pass it dynamically.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5uvAxpbE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xn1y1x29rma0a46uasfq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5uvAxpbE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xn1y1x29rma0a46uasfq.png" alt="Image description" width="307" height="145"&gt;&lt;/a&gt;&lt;br&gt;
Passing the integer value in a variable. We used ($limit : Int!) as a variable and used it further in place of a hard code value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4Qv5rfut--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lphkzfp0fwzstek9gneu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4Qv5rfut--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lphkzfp0fwzstek9gneu.png" alt="Image description" width="800" height="388"&gt;&lt;/a&gt;&lt;br&gt;
Now that the stage is set, let's hit the dance floor with some queries and mutations. Fetching data has never been this groovy!&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Level Up: Advanced GraphQL Moves
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Fragments and Aliases: The Dance Choreography
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Fragments help keep our queries organized, like dance choreography. Aliases let us change field names for a smoother performance.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Pagination and Filtering: The Crowd Control
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Handling a massive crowd of data? We'll talk about pagination and filtering, ensuring a seamless experience for our users.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Real-Time Vibes with Subscriptions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;What's a party without real-time updates? Subscriptions bring the excitement of live music to our app.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Curtain Call: The Future of GraphQL
&lt;/h2&gt;

&lt;p&gt;As our journey comes to an end, let's peek into the crystal ball and see the future of GraphQL. &lt;br&gt;
Spoiler alert: It looks pretty darn exciting YouTube Video is below!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KmOhenjk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qn4dfwgtgevbg6xx0jw2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KmOhenjk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qn4dfwgtgevbg6xx0jw2.png" alt="Image description" width="790" height="603"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/embed/bOiAhmrVaoU?feature=oembed"&gt;https://www.youtube.com/embed/bOiAhmrVaoU?feature=oembed&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Future of GraphQL Panel&lt;/p&gt;

&lt;p&gt;• “GraphQL is going to become ubiquitous as the API access language, and delivers the core value proposition of decoupling the frontend and backend.”&lt;br&gt;
• Hear more insights from Evan Weaver, CTO and co-founder at Fauna.&lt;br&gt;
• "I'm cautiously optimistic. GraphQL has hit a nerve with the problems of API exploration and integrating complex APIs."&lt;br&gt;
• Hear more insights from Tanmai Gopal, CEO and co-founder at Hasura. &lt;/p&gt;

&lt;h2&gt;
  
  
  Closing Act
&lt;/h2&gt;

&lt;p&gt;Time to wield the GraphQL sword in your projects and join the league of developers creating smarter, efficient, and downright cool APIs.&lt;/p&gt;

&lt;p&gt;In this guide, we've had a blast exploring the wonders of GraphQL. Remember, the adventure doesn't end here. Keep pushing the boundaries, experimenting with advanced features, and most importantly, have fun coding!&lt;/p&gt;

&lt;h2&gt;
  
  
  Disclaimer:
&lt;/h2&gt;

&lt;p&gt;This is a personal blog. The views and opinions expressed here are only those of the author and do not represent those of any organization or any individual with whom the author may be associated, professionally or personally.&lt;/p&gt;

&lt;p&gt;Signing off&lt;br&gt;
Amrit Prabhat (QA)&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>api</category>
      <category>testing</category>
      <category>qa</category>
    </item>
  </channel>
</rss>
