GraphQL was introduced to solve some problems with traditional REST APIs. Which of the following best explains the main reason GraphQL exists?
Think about how REST APIs sometimes send too much or too little data.
GraphQL was created to let clients specify exactly what data they want, avoiding the problems of over-fetching (getting too much data) and under-fetching (getting too little data) common in REST APIs.
Which problem is GraphQL designed to solve that is common in REST APIs?
Think about how many times a client might call a REST API to get related data.
GraphQL lets clients get all needed data in one request, avoiding multiple calls to different REST endpoints.
Given this GraphQL query requesting a user's name and their posts' titles, what will the result look like?
{ user(id: "1") { name posts { title } } }The query asks for both name and posts with titles.
The result includes the user's name and an array of posts with their titles as requested.
Which option contains a syntax error in this GraphQL query?
{ user(id: "1") { name posts { title } } }Check for missing brackets or commas.
Option C is missing the closing curly brace at the end, causing a syntax error.
You have a GraphQL query fetching user details and their posts with comments. Which option best reduces data transfer by requesting only necessary fields?
{ user(id: "1") { id name posts { id title comments { id content } } } }Only request fields you need to reduce data size.
Option D removes unnecessary 'id' fields from comments, reducing data transfer while keeping needed info.