GraphQL, the "A" in JAMstack for data management

Felipe SilbersteinAugust 20, 2021

When you venture with JAMstack as a web development methodology for the first time, there are several paradigms that you should rethink. One of them is how your platform manages data, both from the development and the client-side. GraphQL is an API query language ("QL" comes from Query Language) that allows describing data schemas on the backend side, providing the possibility for the client to query the data explicitly required.


Where does the data go when we develop in JAMstack?

What we love the most about JAMstack is its API-First philosophy*.* Creating new platforms with our teams, with the peace of mind of knowing that the features we need can be easily integrated, is fantastic. You stop wasting your team's valuable time in the search for solutions restricted to a single framework or language, a common situation in conventional monolithic platforms.

Focusing on a minimal architecture, this methodology does not need the classic server that hosts your data; rather, it uses a serverless solution that establishes communication with your data via API calls. Thus, while you worry about the content of your data, the serverless infrastructure will oversee your providers.

Without spending time in server configuration, you and your clients can query from a simple API call when you need to call data. It sounds very similar to what we were doing years ago with API-Rest, but this is where the GraphQL innovation comes in.

The origin of GraphQL

Facebook created this language in 2012 by Facebook, but it was only in 2015 that we learned about it. The tech giant took three years to publish its creation; they sought to innovate the mobile application to increase speed, efficiency, and security in a device with less connectivity than desktop computers.

When this language became open source, many companies began to deploy it. The ease with which it allows you to browse through the client-side data in a fast way - without complicating the platform - makes it the go-to language to build the query system.

Thus, from 2018 to the present, GraphQL is a foundation of the same name backed by the Linux Foundation and is responsible for encouraging the development of an ecosystem conducive to adopting this language in web deployments.

Change how you think about your data

GraphQL provides a middleware solution that adds all the necessary information to serve a complete request. It connects to the backend data sources and manages the frontend request by querying the various data sources as the same call and end-point.

  • REST API is usually used in web development to answer a query using the GET method. The client requests information from an entity, and the API responds to the call using the POST method, delivering the result as JSON. In summary: HTTP communication, although in REST, involves one call per entity.
  • In GraphQL, there is only one access point; you will not need to perform a query or an API end-point for each entity that the client needs. With the same query, you define what you need and receive a response only with the requested information.

Create a data schema according to your business

The magic of GraphQL is the creation of a data schema, which is the fundamental structure of understanding that will allow this language to go through each element according to the relationships and nodes are drawn in the schema. At this point, it is essential to involve the entire development team since the creation of this data schema must come from a genuine understanding of the business rules that make up your brand.

Let's think about an e-commerce site: with your team, you should analyze how the client searches for products and browses directly and indirectly related others. Even though they are different entities, you will be able to set a complementary relationship between them, becoming available data to your clients. This is the freedom that comes with creating your own schema.

  • Everything will remain essentially the same on the client-side. You will still be able to request data via API calls without manipulating the server where the information is hosted, similar to using OOP (object-oriented programming).
  • You can use your favorite backend on the server side since GraphQL is framework-agnostic for the backend. This favors deployment for both new JAMstack platforms and old legacy systems using the same REST end-points. If you're still wondering, "what's the difference then?" Pay attention to the following.

The "A" in JAMstack for data management

As we mentioned before, GraphQL allows you to query what you need on the scale you require.

  • When defining a data schema, GraphQL is formatted to allow the retrieval of any object via the node in the base query object. With the above, you get things that conform to a "node" interface that employs standardized methods to deal with relationships.
  • That means goodbye to under-fetching and over-fetching problems in querying data; one of the original reasons that motivated GraphQL was the difficulties related to calls that did not deliver all the information (under-fetching) or, otherwise, responses with more data than required. When you bring this behavior to large platforms, you obtain efficiency in using the computing resources of your serverless services because fewer queries will be needed to satisfy the requirements.
  • Deploying serverless data management is easier than it sounds, thanks to *client-*type developments such as Netlify. These allow you to run pieces of code in AWS Lambda without requiring an Amazon account, so the infrastructure scales automatically when experiencing an increase in queries and frees your company from maintaining servers.
    • Looking back, developing platforms based on API integrations provides organizations with greater freedom. Whether viewed from data management as GraphQL or from content management with Netlify, the vision-driven by these JAMstack technologies is to have greater control over your platform while maintaining the simplicity of your infrastructure.

      Reign will be your partner to evolve towards the JAMstack philosophy. We are loyal followers of this methodology, and we know about each integration in depth. You will find the expert support you need to deploy technology ready to grow with your organization.