0% found this document useful (0 votes)
18 views5 pages

12 Rest and Graphql

Uploaded by

limlyminh059
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views5 pages

12 Rest and Graphql

Uploaded by

limlyminh059
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Backend: A Node + Express REST API

Node /
? Express

POST /post
Server-side
GET /posts Logic,
Client Server
Database
Access etc.
GET /posts/:postId

MongoDB
API Endpoints
REST & Http Methods (Http Verbs)

More than just GET & POST

GET POST PUT

Post a Resource to the Put a Resource onto the


Get a Resource from the
Server (i.e. create or Server (i.e. create or
Server
append Resource) overwrite a Resource)

PATCH DELETE OPTIONS

Update parts of an Determine whether follow-


Delete a Resource on the
existing Resource on the up Request is allowed
Server
Server (sent automatically)
How does GraphQL Work?

Node /
? Express

POST /graphql
Server-side
Logic,
Client Server
Database
POST Request Access etc.
contains Query
Expression (to define
the Data that should
be returned)

MongoDB
One Single Endpoint
A GraphQL Query

ẖ Operation “endpoint”
Operation type I M=JQ ẖ
Other types: MK=J ẖ
mutation
subscription
F9E=
9?=
ẗ Requested fields


REST vs GraphQL
In th
is c o
u rs e
REST API GraphQL API

Request path + http method (=


Query expression identifies a
“endpoint”) identify a resource /
resource and action
action on the server

API is stateless and decoupled from API is stateless and decoupled from
any frontend any frontend

The most common type of API Popular but less common, because
because of its ease of use you need to learn the query language

You might also like