You are on page 1of 18

graphQL

Milan Katira
Swipe →
Introduction

GraphQL is a powerful query language for your API,

providing a more efficient, powerful, and flexible

alternative to the traditional REST API. Developed by

Facebook, GraphQL allows you to request exactly the

data you need, making it ideal for modern web and

mobile applications.

With GraphQL, you define your data schema on the

server, and clients can request precisely the data

they require, reducing over-fetching and under-

fetching of data. This client-driven approach

simplifies communication between clients and

servers and enables a more efficient development

process.

Milan Katira
Swipe →
Architecture

GraphQL architecture is centered around a flexible,

client-driven approach to data retrieval. In GraphQL,

clients request specific data by defining queries, and

servers provide responses according to a predefined

schema.

Milan Katira
Swipe →
Queries in GraphQL

Queries are one of the fundamental components of

GraphQL. They are used by clients to request data

from the server. In a GraphQL query, the client

specifies the shape and structure of the response,

including the fields and relationships it needs. This

contrasts with REST, where the server dictates the

shape of the response.

Milan Katira
Swipe →
Mutations in GraphQL

While queries are used for reading data, mutations

are used for modifying data on the server. Mutations

allow clients to perform create, update, or delete

operations. Like queries, mutations are defined in the

GraphQL schema and can include input arguments.

Milan Katira
Swipe →
backend

with

graphQL

Milan Katira
Swipe →
GraphQL queries and mutations for a "records"

database. They utilize MongoDB to fetch and

manipulate data, including fetching a single record by

ID, retrieving all records, and deleting a record by ID.

Milan Katira
Swipe →
This GraphQL schema defines three main types: `Query`

for fetching records, `Mutation` for creating, updating,

and deleting records, and `Record` to describe the

structure of a record. The schema allows you to retrieve

single records or lists of records, create new records,

delete records, and update existing ones, all with

appropriate data types specified.

Milan Katira
Swipe →
Initializes an Apollo GraphQL server with a defined

schema and resolvers. It configures routing for the

GraphQL endpoint, starts the server, and listens on a

specified port, logging the server's status.

Milan Katira
Swipe →
GraphQL Developer Tools

GraphQL Developer Tools are essential for both frontend

and backend developers working with GraphQL APIs.

These tools include extensions, libraries, and browser-

based GraphiQL interfaces that simplify debugging and

development

Milan Katira
Swipe →
Milan Katira
Swipe →
frontend

with

graphQL

Milan Katira
Swipe →
Initialize

GraphQL with a

backend

Milan Katira
Swipe →
writing Queries

This GraphQL query named `GetRecords` requests a

list of records from the API, including their `id`,

`name`, `position`, and `level` properties.

Milan Katira
Swipe →
fetch data

Apollo Client's useQuery hook to fetch data using the

GET_RECORDS GraphQL query. It handles different

states

Milan Katira
Swipe →
Write mutation

The `DELETE_RECORD` GraphQL mutation is

designed to delete a record from the API by

specifying its unique identifier (`$id`) as an input

parameter.

Milan Katira
Swipe →
delete data

Apollo Client's useQuery hook to fetch data using the

GET_RECORDS GraphQL query. It handles different

states

Milan Katira
Swipe →
Thanks for
reading

Like, Comment & Share Save This Post

You might also like