avatarDineshchandgr - A Top writer in Technology

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

8107

Abstract

lass="hljs-string">"price"</span>: <span class="hljs-number">13</span> } ] } }</pre></div><p id="4277">Let's say now another client can query like this with an extra field and the server would respond with 3 fields</p><div id="f093"><pre><span class="hljs-keyword">query</span> {</pre></div><div id="ef37"><pre> <span class="hljs-keyword">students</span> {</pre></div><div id="63f1"><pre> <span class="hljs-keyword">name</span></pre></div><div id="f8ab"><pre><span class="hljs-attribute"> age</span></pre></div><div id="6f63"><pre> <span class="hljs-built_in">id</span></pre></div><div id="6833"><pre> }</pre></div><div id="fd1c"><pre>}</pre></div><p id="317a">The response is as follows. Here the response contains the extra id field asked by the client. This is the real power of GraphQL where the Client can only get the fields they need.</p><div id="7213"><pre>{ <span class="hljs-string">"data"</span>: { <span class="hljs-string">"students"</span>: [ { <span class="hljs-string">"name"</span>: <span class="hljs-string">"xxxx"</span>, <span class="hljs-string">"age"</span>: <span class="hljs-number">12</span>, <span class="hljs-string">"id"</span>: <span class="hljs-number">1</span> }, { <span class="hljs-string">"name"</span>: <span class="hljs-string">"yyyy"</span>, <span class="hljs-string">"age"</span>: <span class="hljs-number">10</span>, <span class="hljs-string">"id"</span>: <span class="hljs-number">2</span> }, { <span class="hljs-string">"name"</span>: <span class="hljs-string">"zzzz"</span>, <span class="hljs-string">"age"</span>: <span class="hljs-number">13</span>, <span class="hljs-string">"id"</span>: <span class="hljs-number">3</span> } ] } }</pre></div><h2 id="c722">2. Mutation:</h2><p id="5e90">The mutation is used to add, edit or delete data from the server.</p><p id="ce29">Instead of the Query keyword, we need to use the mutation keyword and there are 3 types of operations that can be performed using the mutation</p><ul><li>create a new record</li><li>update existing record</li><li>delete a record</li></ul><p id="5798">As you can see these are exactly like the CRUD operations in the REST API calls. We pass the data needed as params and get the provided field values in response</p><p id="f767">The mutation to add a student will add the below record in the database and the JSON response is shown below</p><div id="6127"><pre><span class="hljs-attribute">Request</span></pre></div><div id="8a3a"><pre>mutation { addStudent<span class="hljs-built_in">(id</span>: <span class="hljs-number">1</span>,<span class="hljs-built_in"> name</span>: <span class="hljs-string">"xxx"</span>, age: <span class="hljs-number">12</span>) { <span class="hljs-built_in"> id</span> <span class="hljs-built_in"> name</span> age } }</pre></div><div id="647f"><pre><span class="hljs-attribute">Response</span></pre></div><div id="0c19"><pre><span class="hljs-punctuation">{</span> <span class="hljs-attr">"data"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span> <span class="hljs-attr">"addStudent"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span> <span class="hljs-attr">"id"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">1</span> <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"xxxx"</span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"age"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">12</span> <span class="hljs-punctuation">}</span> <span class="hljs-punctuation">}</span> <span class="hljs-punctuation">}</span></pre></div><p id="4bb9">Now let us use the update mutation to update the name of the student with id 1. The response provides the updated name</p><div id="e9df"><pre><span class="hljs-attribute">Request</span></pre></div><div id="9e53"><pre>mutation { updateStudent<span class="hljs-built_in">(id</span>: <span class="hljs-number">1</span>,<span class="hljs-built_in"> name</span>: <span class="hljs-string">"yyyy"</span>) { <span class="hljs-built_in"> id</span> <span class="hljs-built_in"> name</span> } }</pre></div><div id="c64b"><pre><span class="hljs-attribute">Response</span></pre></div><div id="9155"><pre><span class="hljs-punctuation">{</span> <span class="hljs-attr">"data"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span> <span class="hljs-attr">"updateStudent"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span> <span class="hljs-attr">"id"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">1</span> <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"yyyy"</span><span class="hljs-punctuation">,</span> <span class="hljs-punctuation">}</span> <span class="hljs-punctuation">}</span> <span class="hljs-punctuation">}</span></pre></div><p id="ef01">Now let us delete the student record with a delete mutation. The student with 1 is deleted and the response is provided</p><div id="d189"><pre><span class="hljs-keyword">mutation</span> { deleteStudent(<span class="hljs-built_in">id</span><span class="hljs-operator">:</span> 6) { <span class="hljs-built_in">id</span> name } }</pre></div><div id="50e0"><pre><span class="hljs-punctuation">{</span> <span class="hljs-attr">"data"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span> <span class="hljs-attr">"deleteStudent"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span> <span class="hljs-attr">"id"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">1</span> <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"yyyy"</span><span class="hljs-punctuation">,</span> <span class="hljs-punctuation">}</span> <span class="hljs-punctuation">}</span> <span class="hljs-punctuation">}</span></pre></div><h2 id="90d2">3. Subscription:</h2><p id="8919">Subscriptions are similar to Queries to fetch data but it allows the client to receive real-time updates from the server using Socket.io by setting up real-time communication between the client and server. GraphQL has this inbuilt functionality.</p><p id="cf65">GraphQL subscriptions allow clients to listen when data is created, updated, or deleted on the server. These events are pushed from the server to the subscribed clients.</p><p id="2998">Clients subscribe to a server-side event by using the subscription query:</p><div id="56aa"><pre>subscription NewsFeed {

newsCreated {

<span class="hljs-code"> title </span> <span class="hljs-code"> body </span> }

}</pre></div><p id="ba51">This subscription will be for the newsCreated field.</p><p id="a1bf">The GraphQL Subscriptions use WebSocket for communication instead of the normal POST method which queries and mutations use. Subscriptions maintain an active connection to the server listening and waiting for the server to push updates to it.</p><p id="8804">You can try out the GraphQL Queries and Mutations in the below link</p><div id="3728" class="link-block"> <a href="https://www.predic8.de/graphql-query-samples.htm"> <div> <div> <h2>GraphQL Query and Mutation Examples</h2> <div><h3>Here you can find examples for GraphQL-Queries and mutations to try out with one click. The database of the GraphQL…</h3></div> <div><p>www.predic8.de</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/)"></div> </div> </div> </a> </div><h1 id="0137">GraphQL Architectural Patterns</h1><p id="c201">As seen in this article,

Options

GraphQL follows a typical <b>client-server architectural pattern</b>. The GraphQL server can be used in 3 different architecture styles as follows</p><h1 id="14a0">1. GraphQL Server with Connected Database</h1><figure id="b27b"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*v1SBMqK3-umGSgnYRR2Erg.jpeg"><figcaption>Source: <a href="https://progressivecoder.com/wp-content/uploads/2022/01/graphql-architectural-patterns-connected-db.png?ezimgfmt=ng:webp/ngcb1">https://progressivecoder.com/wp-content/uploads/2022/01/graphql-architectural-patterns-connected-db.png?ezimgfmt=ng:webp/ngcb1</a></figcaption></figure><p id="8b42">In this architecture, the GraphQL server is connected to the database and this architecture is good for new projects. The server receives the query from the client, fetches the data, and provides a response to the client. This is called Query resolution.</p><p id="b538">GraphQL server can connect to any type of database for eg: MySQL, MongoDB, AWS Aurora, etc.</p><p id="143e">The advantage of this pattern is the requests can be served with low latency as the data source is close to the GraphQL server.</p><h1 id="d417">2. GraphQL Server integrated with the Existing System</h1><p id="b44a">In this pattern, the GraphQL server is used to abstract the different services from the client</p><figure id="9113"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*YnoENi7PL8Qxz2hHjs_F0A.jpeg"><figcaption>Image Source: <a href="https://progressivecoder.com/wp-content/uploads/2022/01/graphql-architectural-patterns-existing-system.png?ezimgfmt=ng:webp/ngcb1">https://progressivecoder.com/wp-content/uploads/2022/01/graphql-architectural-patterns-existing-system.png?ezimgfmt=ng:webp/ngcb1</a></figcaption></figure><p id="255e">In larger organizations, there might be big projects that interact with different systems like Third Party services, some new microservices, and legacy systems. In this scenario, if we want to implement GraphQL, then this architecture is more suited as it hides the complexity of all the systems and the clients can call the GraphQL server to obtain data according to the client’s requirement thereby getting the benefits of GraphQL</p><h1 id="36bc">3. Hybrid approach with connected database and integration of existing system</h1><p id="f61f">In this hybrid approach, the GraphQL server is connected to its own data source and also it will interact with the legacy systems.</p><figure id="b464"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*XjBC_zGz6Haov2P1-MFaBQ.jpeg"><figcaption>Image Source: <a href="https://progressivecoder.com/wp-content/uploads/2022/01/graphql-architectural-patterns-hybrid.png?ezimgfmt=ng:webp/ngcb1">https://progressivecoder.com/wp-content/uploads/2022/01/graphql-architectural-patterns-hybrid.png?ezimgfmt=ng:webp/ngcb1</a></figcaption></figure><p id="1b72">The GraphQL will try to look for the data in the database and if not found, it will get from the legacy systems. This approach is best used for incremental migration of legacy systems into the new GraphQL server. Once the migration is completed, then the whole architecture will be back to the <b>“GraphQL server with the connected Database” </b>pattern</p><h2 id="3088">REST vs GraphQL</h2><p id="dcdb">Having seen in-depth GraphQL, let's compare it with REST.</p><p id="8431">In the REST architecture style, we have multiple endpoints and the client will call the relevant endpoints and these endpoints will be talking to the service layer.</p><p id="fdb8">The graph layer only exposes a single endpoint through GraphQL and it will connect to the service layer to retrieve the data.</p><p id="15b0">REST is a type of architecture pattern while GraphQL is particularly a query language.</p><figure id="fecc"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*5YF6aTDmet24GwD3asZyQQ.png"><figcaption>Image Source: <a href="https://wp.apollographql.com/wp-content/uploads/2021/10/graph-layer-example-1024x596.png">https://wp.apollographql.com/wp-content/uploads/2021/10/graph-layer-example-1024x596.png</a></figcaption></figure><figure id="6b9e"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*2S2BrSgWTos5BpKZa5H98g.png"><figcaption></figcaption></figure><p id="1981">We need to consider a lot of factors as mentioned above when choosing between GraphQL vs REST. GraphQL would be ideal for mobile clients that need better performance. It is also useful in a system where there are a lot of data sources. If you are dealing with frequent changes in the data source, then GraphQL is suitable as you can swap the resolvers easily.</p><h1 id="15dd">Summary</h1><p id="fd16">In this article, we started to understand what is an API and what is a REST API. Then we saw GraphQL and how the client-server communication happens in GraphQL. Later we saw the operations performed in GraphQL and also about the 3 architectural styles that can be used. Then we compared GraphQL with REST to conclude this article.</p><p id="bdcb">Please read my next article on GraphQL</p><div id="eb99" class="link-block"> <a href="https://dineshchandgr.medium.com/how-to-use-graphql-with-spring-boot-7a4d66ed84d7"> <div> <div> <h2>How to use GraphQL with Spring Boot?</h2> <div><h3>Hello everyone. In my previous article, I have written in-depth about GraphQL. Please take a look at the article before…</h3></div> <div><p>dineshchandgr.medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*4WOc-E_SoW60W1uNTH8VrQ.png)"></div> </div> </div> </a> </div><p id="c71a">Hope this was useful and thanks for reading this!!!</p><div id="e53f"><pre><span class="hljs-keyword">If</span> you <span class="hljs-built_in">like</span> <span class="hljs-keyword">to</span> <span class="hljs-keyword">get</span> more updates <span class="hljs-keyword">from</span> <span class="hljs-keyword">me</span>, please follow <span class="hljs-keyword">me</span> <span class="hljs-keyword">on</span> Medium <span class="hljs-built_in">and</span> subscribe <span class="hljs-keyword">to</span> email alert.</pre></div><div id="e0ec"><pre><span class="hljs-keyword">If</span> you are considering <span class="hljs-keyword">to</span> buy a medium membership, please buy through my referral <span class="hljs-keyword">link</span> https:<span class="hljs-comment">//dineshchandgr.medium.com/membership</span></pre></div><div id="c5ef" class="link-block"> <a href="https://readmedium.com/microservices-communication-part-1-every-programmer-must-know-7c6607d2d563"> <div> <div> <h2>Microservices Communication part 1-every programmer must know</h2> <div><h3>Hello Everyone. Microservices communication is the heartbeat of any microservices architecture and designing them could…</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*rLgpLW2MfZ9aWGz0HI6Lig.png)"></div> </div> </div> </a> </div><div id="9c5e" class="link-block"> <a href="https://dineshchandgr.medium.com/microservices-communication-part-2-sync-vs-async-vs-hybrid-23d057e137d8"> <div> <div> <h2>Microservices Communication — part 2 — Sync vs Async vs Hybrid?</h2> <div><h3>Hello Everyone. In the previous article, we saw that there are just 3 ways of communication between the services i.e…</h3></div> <div><p>dineshchandgr.medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*MxWULh-sB1kSemOpx4OE4A.png)"></div> </div> </div> </a> </div></article></body>

Do you know about GraphQL — The Query language for API s?

Hello everyone. We are going to see about an interesting technology called GraphQL, which is an open-source data query and manipulation language for APIs. GraphQL technology was developed by Facebook in 2012 for internal usage and it was publicly released in 2015. After being made open source, the GraphQL project was moved from Facebook to the newly-established GraphQL Foundation in 2018.

Image Source: https://assets.website-files.com/5ff66329429d880392f6cba2/6148414ebf08d4f286ba0f23_What%20is%20GraphQL.png

Let us understand some basics before we dive deep into the GraphQL

What is an API?

Image Source: https://www.cleveroad.com/images/article-previews/40ca78a7a9db7adfb6bb861fc6b8910ae2ef4bb79f5508007d166f01df5c1038.png

API stands for Application Programming Interface and is a way to communicate between different services. They let our product or service communicate with other products or services without knowing much about the implementation details. Eg: Google Maps API provides us the geographical information without us knowing about the implementation behind it.

APIs are also like contracts between 2 systems i.e an agreement between them on how to communicate specific requests or responses. APIs are also used to connect our infrastructure through cloud-native app development and to share data with customers and other external users.

What is a REST API?

When we think about APIs, the first thing that comes to our mind is REST API. The REST API is based on HTTP Protocol and it is stateless and is used to retrieve data from servers by URLs.

REST was developed in 2000 and it was considered an excellent fit for web applications as it provided many advantages over the famous SOAP APIs format which was based on XML.

Nowadays APIs have become more complex and data-driven which brings the following drawbacks to using REST APIs.

  • Increased mobile usage brings the necessity to load the data efficiently.
  • Nowadays there are different types of clients and it is difficult for REST APIs to satisfy satisfies their needs, as it returns a fixed data structure.
  • REST makes it slower on the feature development of dynamic web and mobile applications.

What is GraphQL?

Image Source: https://www.loginradius.com/blog/static/7de39de94c321c5ef5ad1991b63fc1ee/e8950/wrapper.png

GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data.

GraphQL stands for Graph Query Language, which is considered an alternative to the REST-based architecture by solving its drawbacks mentioned above. Unlike REST, GraphQL allows the client to ask only for specific fields instead of getting all the values in the response from the server.

When sending queries to your API, GraphQL returns a very predictable result, without any over-fetching or under-fetching, ensuring that apps using GraphQL are fast, stable, and scalable.

Imagine a scenario where an API always returns 100 fields and a client needs to use just 5 fields. We don't need the 95 fields in response but in REST API we don't have a choice but to receive all. Using GraphQL on top of REST API, a client can ask only 5 fields in the API response thereby saving network bandwidth and improving latency.

GraphQL also supports reading, writing, and subscribing to changes to data. GraphQL is provided for multiple languages including Haskell, JavaScript, Perl, Python, Ruby, Java, C++, C#, Scala, Go, Erlang, PHP, and R, which shows its popularity of it.

In a nutshell, using GraphQL

  1. Clients can specify exactly what data they need avoiding under-fetching or over fetching
  2. We can aggregate data from multiple sources
  3. GraphQL uses a type system to describe data rather than endpoints.

Client Server Communication in GraphQL

GraphQL requests can be sent through multiple protocols like HTTP, Websockets, etc but HTTP is the most popular choice. Let us see the steps needed for client-server communication using GraphQL

1. The client (Web, Mobile) sends a GraphQL operation using the HTTP Request.

2. When a client makes a request to send a GraphQL query to the server, it is sent as Query String and not JSON.

3. Once the server receives the request, it extracts the query string, processes it, and validates the GraphQL query.

4. The GraphQL API server makes calls to a database or other services to retrieve the data based on the query and sends the response in JSON format to the client

GraphQL Request and Response

Let us look at the operations performed in GraphQL and the request and response structure in this section

Root Operations in GraphQL

There are 3 root operation types that can be performed in a GraphQL request

1. Query:

Used to read data from the GraphQL API endpoint. The query is sent as a payload to the GraphQL server endpoint via POST request and the GraphQL engine parses the query, executes it against the resolver, and then sends them back to the client.

The following is the schema for the Student object created in the GraphQL server which is shared with the client

type Student {  
  id: String   
  name: String    
  age: String  
 }

A query looks like below

query {
  students {
    name
    age
  }
}

The request is a query for student data from the server. And we wanted to retrieve the name and ages of students even though the Student object has a lot of fields.

The response for the above query is in JSON format as below. It retrieves only the name and age of all the students in the database

{
  "data": {
    "students": [
      {
        "name": "xxxx",
        "age": 12
      },
      {
        "name": "yyyy",
        "price": 10
      },
      {
        "name": "zzzz",
        "price": 13
      }
    ]
  }
}

Let's say now another client can query like this with an extra field and the server would respond with 3 fields

query {
 students {
   name
   age
   id
  }
}

The response is as follows. Here the response contains the extra id field asked by the client. This is the real power of GraphQL where the Client can only get the fields they need.

{
  "data": {
    "students": [
      {
        "name": "xxxx",
        "age": 12,
        "id": 1
      },
      {
        "name": "yyyy",
        "age": 10,
        "id": 2
      },
      {
        "name": "zzzz",
        "age": 13,
        "id": 3
      }
    ]
  }
}

2. Mutation:

The mutation is used to add, edit or delete data from the server.

Instead of the Query keyword, we need to use the mutation keyword and there are 3 types of operations that can be performed using the mutation

  • create a new record
  • update existing record
  • delete a record

As you can see these are exactly like the CRUD operations in the REST API calls. We pass the data needed as params and get the provided field values in response

The mutation to add a student will add the below record in the database and the JSON response is shown below

Request
mutation {
  addStudent(id: 1, name: "xxx", age: 12) {
    id
    name
    age
   }
}
Response
{
  "data": {
    "addStudent": {
      "id": 1
      "name": "xxxx",
      "age": 12
     }
  }
}

Now let us use the update mutation to update the name of the student with id 1. The response provides the updated name

Request
mutation {
  updateStudent(id: 1, name: "yyyy") {
    id
    name
  }
}
Response
{
  "data": {
    "updateStudent": {
      "id": 1
      "name": "yyyy",
      }
  }
}

Now let us delete the student record with a delete mutation. The student with 1 is deleted and the response is provided

mutation {
  deleteStudent(id: 6) {
    id
    name
  }
}
{
  "data": {
    "deleteStudent": {
      "id": 1
      "name": "yyyy",
      }
  }
}

3. Subscription:

Subscriptions are similar to Queries to fetch data but it allows the client to receive real-time updates from the server using Socket.io by setting up real-time communication between the client and server. GraphQL has this inbuilt functionality.

GraphQL subscriptions allow clients to listen when data is created, updated, or deleted on the server. These events are pushed from the server to the subscribed clients.

Clients subscribe to a server-side event by using the subscription query:

subscription NewsFeed {

  newsCreated {

    title

    body

  }

}

This subscription will be for the newsCreated field.

The GraphQL Subscriptions use WebSocket for communication instead of the normal POST method which queries and mutations use. Subscriptions maintain an active connection to the server listening and waiting for the server to push updates to it.

You can try out the GraphQL Queries and Mutations in the below link

GraphQL Architectural Patterns

As seen in this article, GraphQL follows a typical client-server architectural pattern. The GraphQL server can be used in 3 different architecture styles as follows

1. GraphQL Server with Connected Database

Source: https://progressivecoder.com/wp-content/uploads/2022/01/graphql-architectural-patterns-connected-db.png?ezimgfmt=ng:webp/ngcb1

In this architecture, the GraphQL server is connected to the database and this architecture is good for new projects. The server receives the query from the client, fetches the data, and provides a response to the client. This is called Query resolution.

GraphQL server can connect to any type of database for eg: MySQL, MongoDB, AWS Aurora, etc.

The advantage of this pattern is the requests can be served with low latency as the data source is close to the GraphQL server.

2. GraphQL Server integrated with the Existing System

In this pattern, the GraphQL server is used to abstract the different services from the client

Image Source: https://progressivecoder.com/wp-content/uploads/2022/01/graphql-architectural-patterns-existing-system.png?ezimgfmt=ng:webp/ngcb1

In larger organizations, there might be big projects that interact with different systems like Third Party services, some new microservices, and legacy systems. In this scenario, if we want to implement GraphQL, then this architecture is more suited as it hides the complexity of all the systems and the clients can call the GraphQL server to obtain data according to the client’s requirement thereby getting the benefits of GraphQL

3. Hybrid approach with connected database and integration of existing system

In this hybrid approach, the GraphQL server is connected to its own data source and also it will interact with the legacy systems.

Image Source: https://progressivecoder.com/wp-content/uploads/2022/01/graphql-architectural-patterns-hybrid.png?ezimgfmt=ng:webp/ngcb1

The GraphQL will try to look for the data in the database and if not found, it will get from the legacy systems. This approach is best used for incremental migration of legacy systems into the new GraphQL server. Once the migration is completed, then the whole architecture will be back to the “GraphQL server with the connected Database” pattern

REST vs GraphQL

Having seen in-depth GraphQL, let's compare it with REST.

In the REST architecture style, we have multiple endpoints and the client will call the relevant endpoints and these endpoints will be talking to the service layer.

The graph layer only exposes a single endpoint through GraphQL and it will connect to the service layer to retrieve the data.

REST is a type of architecture pattern while GraphQL is particularly a query language.

Image Source: https://wp.apollographql.com/wp-content/uploads/2021/10/graph-layer-example-1024x596.png

We need to consider a lot of factors as mentioned above when choosing between GraphQL vs REST. GraphQL would be ideal for mobile clients that need better performance. It is also useful in a system where there are a lot of data sources. If you are dealing with frequent changes in the data source, then GraphQL is suitable as you can swap the resolvers easily.

Summary

In this article, we started to understand what is an API and what is a REST API. Then we saw GraphQL and how the client-server communication happens in GraphQL. Later we saw the operations performed in GraphQL and also about the 3 architectural styles that can be used. Then we compared GraphQL with REST to conclude this article.

Please read my next article on GraphQL

Hope this was useful and thanks for reading this!!!

If you like to get more updates from me, please follow me on Medium and subscribe to email alert.
If you are considering to buy a medium membership, please buy through my referral link https://dineshchandgr.medium.com/membership
Software Development
Software Engineering
Programming
Coding
Technology
Recommended from ReadMedium