@@ -56,7 +56,7 @@ REST is built on six fundamental principles:
5656
5757### REST API Example with Full CRUD Operations:  
5858
59- ``` javascript:numberLines  
59+ ``` javascript 
6060//  Get all users with pagination
6161GET  / api/ users? page= 1 & limit= 10 & sort= name& order= asc
6262
@@ -117,7 +117,7 @@ Content-Type: application/json
117117
118118### HTTP Status Codes in REST:  
119119
120- ``` javascript:numberLines  
120+ ``` javascript 
121121//  Success Responses
122122200  OK  -  Request succeeded
123123201  Created -  Resource created successfully
@@ -185,7 +185,7 @@ GraphQL is built on several key concepts:
185185
186186### GraphQL Schema Example:  
187187
188- ``` graphql:numberLines  
188+ ``` graphql 
189189# Schema Definition 
190190type  User  {
191191  id : ID ! 
@@ -260,7 +260,7 @@ scalar DateTime
260260
261261### GraphQL Query Examples:  
262262
263- ``` graphql:numberLines  
263+ ``` graphql 
264264# Basic Query 
265265query  GetUser ($userId : ID ! ) {
266266  user (id : $userId ) {
@@ -341,7 +341,7 @@ query SearchUsers($query: String!, $limit: Int = 10, $offset: Int = 0) {
341341
342342### GraphQL Mutation Examples:  
343343
344- ``` graphql:numberLines  
344+ ``` graphql 
345345# Create User Mutation 
346346mutation  CreateUser ($input : CreateUserInput ! ) {
347347  createUser (input : $input ) {
@@ -382,7 +382,7 @@ mutation BatchCreateUsers($inputs: [CreateUserInput!]!) {
382382
383383### GraphQL Subscription Example:  
384384
385- ``` graphql:numberLines  
385+ ``` graphql 
386386# Real-time User Updates 
387387subscription  UserUpdates ($userId : ID ! ) {
388388  userUpdated (id : $userId ) {
@@ -443,7 +443,7 @@ subscription NewPosts {
443443
444444#### REST Data Fetching:  
445445
446- ``` javascript:numberLines  
446+ ``` javascript 
447447//  REST requires multiple requests for related data
448448//  Request 1: Get user
449449const  userResponse  =  await  fetch (' /api/users/123' 
@@ -466,7 +466,7 @@ const settings = await settingsResponse.json();
466466
467467#### GraphQL Data Fetching:  
468468
469- ``` graphql:numberLines  
469+ ``` graphql 
470470# Single request gets all needed data 
471471query  GetUserComplete ($userId : ID ! ) {
472472  user (id : $userId ) {
@@ -497,7 +497,7 @@ query GetUserComplete($userId: ID!) {
497497
498498#### REST Error Handling:  
499499
500- ``` javascript:numberLines  
500+ ``` javascript 
501501//  REST uses HTTP status codes
502502try  {
503503  const  response  =  await  fetch (' /api/users/123' 
@@ -520,7 +520,7 @@ try {
520520
521521#### GraphQL Error Handling:  
522522
523- ``` graphql:numberLines  
523+ ``` graphql 
524524# GraphQL returns partial data with errors 
525525query  GetUserWithPosts ($userId : ID ! ) {
526526  user (id : $userId ) {
@@ -561,7 +561,7 @@ query GetUserWithPosts($userId: ID!) {
561561
562562#### REST Caching:  
563563
564- ``` javascript:numberLines  
564+ ``` javascript 
565565//  REST has built-in HTTP caching
566566const  response  =  await  fetch (' /api/users/123' 
567567  headers:  {
@@ -578,7 +578,7 @@ const response = await fetch('/api/users/123', {
578578
579579#### GraphQL Caching:  
580580
581- ``` javascript:numberLines  
581+ ``` javascript 
582582//  GraphQL requires custom caching strategies
583583import  { ApolloClient , InMemoryCache , createHttpLink  } from  ' @apollo/client' 
584584
0 commit comments