GraphQL uses a single endpoint for all queries and mutations. What is the primary benefit of this approach compared to REST APIs with multiple endpoints?
Think about how many requests a client needs to make to get data in REST vs GraphQL.
Using a single endpoint allows clients to specify exactly what data they want, reducing multiple network calls and improving efficiency.
Given the schema with a single endpoint, what will be the result of this query?
{ user(id: "1") { name, posts { title } } }query { user(id: "1") { name, posts { title } } }Look at the query requesting user name and posts titles.
The query asks for user with id 1, including their name and posts titles, so the response includes both.
Select the syntactically correct GraphQL query to fetch a user's name and their posts' titles.
Remember that GraphQL uses commas to separate fields, not semicolons or colons in this context.
Option D uses correct syntax with commas separating fields and proper nesting.
Which option best explains how single endpoint architecture helps optimize data fetching?
Think about how clients control the data they receive in GraphQL.
Single endpoint lets clients request only needed fields, avoiding extra data transfer and improving efficiency.
Given the query below, why does it produce an error?
{ user(id: 1) { name, posts { title } } }Error: Argument "id" has invalid value 1.
query { user(id: 1) { name, posts { title } } }Check the type of the id argument in the schema.
The id argument expects a string, so passing a number causes a type error.