GraphQL
Wellerson
@wellers0n
@wellers0n_
Developer

Motivation

    Data fetching
    Pagination with cursor
    Documentation

Overview

    What is GraphQL ?
    Under fetching
    Over fetching
    Query
    Mutation
    URL version
    GraphQL Object Type
    Types
    Request numbers
    Cursor
    Documentation
    Code

GraphQL vs REST

What is an Under fetching

Under fetching is when you get less data than you need

What is an Over fetching

It's when you get more data than you need (like some fields on the JSON that you don't need)

How does a query work?

We need to get some data
    Name
    Email
    Description

REST api request

https://fix.dev/api/user/60f291031a6d0b68dc2a149b/

GraphQL Query type

GraphQL api request

GraphQL query

GraphQL api response

GraphQL response

How does a mutation work?

rest vs graphql

Delete an user

define a mutation

Using mutation

Mutation response

fetch N endpoints

Get users list and user

With Graphql

URL version

    https://fix.dev/api/v1/user/1/
    https://fix.dev/api/v2/user/2/
    https://fix.dev/api/v3/user/3/

GraphQL Object Type

Types

Request numbers

With GraphQL

Response

Pagination

Offset vs Cursor

Cursor

Delete Sam Drunk photos #1 and #2

Page 2 no cat photos

Documentation

Documentation user

References

  • Is offset pagination dead?
  • Explaining GraphQL Connections
  • How to implement Pagination and Mutation in GraphQL
  • A deep dive into the Relay store

Thanks