Skip to content

GraphQL is an open source server-side technology which was developed by Facebook to optimize RESTful API calls. It is an execution engine and a data query language

Notifications You must be signed in to change notification settings

sujoyghoshal/GraphQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL Introduction

GraphQL      React      GitHub      Apollo Server

GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with your existing data. It was developed by Facebook in 2012 and released publicly in 2015 to optimize and improve the efficiency of RESTful APIs.

What is GraphQL?

GraphQL is a powerful tool that allows clients to request exactly the data they need, no more and no less. It empowers front-end developers by providing a flexible and precise way to communicate with APIs.

  • Execution Engine: GraphQL executes queries by leveraging a schema that defines the types of data and relationships between them.
  • Data Query Language: It enables clients to query their API using a syntax that is intuitive and easy to understand.

Learn more about GraphQL: GraphQL Official Website

Why Use GraphQL?

1. Precise Data Fetching

  • With GraphQL, clients can request only the data they need, reducing the amount of data transferred over the network. This leads to faster and more efficient applications.

2. Single Endpoint

  • Unlike REST, where you might need multiple endpoints to retrieve related data, GraphQL allows you to fetch all necessary data in a single request.

3. Strongly Typed Schema

  • GraphQL operates on a strongly typed schema, which provides clear definitions of the data structures, ensuring more predictable and reliable API interactions.

4. Real-time Data with Subscriptions

  • GraphQL supports real-time updates through subscriptions, making it ideal for applications that require live data, such as chat apps or stock tickers.

GraphQL vs. REST

While REST has been the traditional choice for building APIs, GraphQL offers several advantages:

Feature GraphQL REST
Data Fetching Single request for precisely the data needed Multiple endpoints, potential over-fetching
Versioning No versioning needed, evolve schema smoothly Requires versioning, multiple versions can exist
Flexibility High flexibility with queries Limited flexibility, predefined responses
Real-time Supports real-time updates via subscriptions Requires additional protocols like WebSockets

Key Features of GraphQL

  • Declarative Data Fetching: Clients can request specific data, making API responses predictable and efficient.
  • Strongly Typed Schema: The schema acts as a contract between the client and server, ensuring consistency and reliability.
  • Introspection: Clients can query the schema itself to understand the available data and operations.
  • Hierarchical Queries: Data can be fetched in a nested, hierarchical structure, which mirrors the data's relationship in the backend.
  • Mutations: GraphQL supports not only querying data but also modifying it through mutations.

Getting Started

Backend Setup with Apollo Server

Apollo Server is a community-driven, open-source GraphQL server that is compatible with any GraphQL schema. It is easy to set up and works seamlessly with various data sources.

Installation

npm install apollo-server graphql

About

GraphQL is an open source server-side technology which was developed by Facebook to optimize RESTful API calls. It is an execution engine and a data query language

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published