Skip to main content

GraphQL Engine

grapgQL

What is GraphQL Engine?

  • GraphQL is a specification (query language) of how to talk to an API. It’s typically used over HTTP where the key idea is to POST a β€œquery” to an HTTP endpoint, instead of hitting different HTTP endpoints for different resources.
  • GraphQL is designed for developers of web/mobile apps to be able to make API calls to fetch exactly the data they need from their backend APIs.
  • GraphQL defines a standard grammar for a query language to read/write data

Why to use GraphQL Engine?

  • Developers love using GraphQL because it’s the most convenient API for JSON data.
  • GraphQL is easy to read and debug, and has a rich ecosystem of community tooling.
  • GraphQL is database agnostic and can be used with any language or framework.
  • GraphQL Schema and Type System contract enables frontend and backend developers to collaborate and work independently.
  • GraphQL is designed to make APIs fast, flexible, and developer-friendly. It can even be deployed within an integrated development environment (IDE) known as GraphiQL.

History of GraphQL

πŸ“† GraphQL was developed internally by Facebook in 2012 before being publicly released in 2015.

πŸ“† On 7 November 2018, the GraphQL project was moved from Facebook to the newly-established GraphQL Foundation, hosted by the non-profit Linux Foundation.

πŸ“† Since 2012, GraphQL's rise has followed the adoption timeline as set out by Lee Byron, GraphQL's creator, with accuracy. Byron's goal is to make GraphQL omnipresent across web platforms.

Advantage of GraphQL Engine

  • A GraphQL schema sets a single source of truth in a GraphQL application. It offers an organization a way to federate its entire API.
  • GraphQL calls are handled in a single round trip. Clients get what they request with no overfetching.
  • Strongly defined data types reduce miscommunication between the client and the server.
  • GraphQL is introspective. A client can request a list of data types available. This is ideal for auto-generating documentation.
  • GraphQL allows an application API to evolve without breaking existing queries.
  • Many open source GraphQL extensions are available to offer features not available with REST APIs.
  • GraphQL does not dictate a specific application architecture. It can be introduced on top of an existing REST API and can work with existing API management tools.

Disadvantage of GraphQL Engine

  • GraphQL presents a learning curve for developers familiar with REST APIs.
  • GraphQL shifts much of the work of a data query to the server side, which adds complexity for server developers.
  • Depending on how it is implemented, GraphQL might require different API management strategies than REST APIs, particularly when considering rate limits and pricing. Caching is more complex than with REST.
  • API maintainers have the additional task of writing maintainable GraphQL schema.

Example of GraphQL Query

This will ask an API to return specific fields in a shape you’ve specified.

 {
me {
name
}
}

This is the result in JSON Format

{
"me": {
"name": "EDWARD"
}
}

Passing argument in Query

{
human(id: "1000") {
name
height
}
}

It will give result as : πŸ“

  {
"data": {
"human": {
"name": "David",
"height": 1.72
}
}
}

Some GraphQL IDE'S With Reference

  • GraphQL Playground is an IDE by Prisma built off of GraphiQL. It takes the best parts of GraphiQL and adds features and improvements, like a better query history display and more ergonomic exploration and debugging.
  • 🎯GraphQL Playgroud

playgrounf

  • GraphiQL Made by the GraphQL Foundation, GraphiQL is an interactive in-browser IDE built on React. It is probably the most popular and lightweight GraphQL IDE out there.The GraphiQL IDE supports the full GraphQL Language Spec, ranging from Queries and Mutations to Fragments and Unions.
  • 🎯GraphiQL

graphiql

πŸ“Œ References