Why does the client send all queries to a single endpoint instead of multiple URLs?
Because the single endpoint parses the query to know exactly what data is needed, avoiding multiple endpoints and simplifying communication, as shown in execution_table steps 1 and 2.
How does the server know which fields to fetch from the database?
The server parses the query to identify requested fields (step 2), then resolves each field by fetching only the necessary data (steps 3-6), avoiding extra data retrieval.
What happens if a requested field is not available in the database?
The resolver for that field returns null or an error, but the rest of the query continues resolving, ensuring partial data can still be returned, as implied by the stepwise resolution in execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the result after step 4?
AResponse ready
BUser name obtained
CPosts data retrieved
DQuery received
💡 Hint
Check the 'Result' column in row for step 4 in execution_table
At which step does the server fetch posts related to the user?
AStep 3
BStep 7
CStep 5
DStep 2
💡 Hint
Look at the 'Action' and 'Details' columns in execution_table for fetching posts
If the client requested only the user's name, which steps would be skipped?
ASteps 5 and 6
BSteps 3 and 4
CSteps 7 and 8
DNo steps skipped
💡 Hint
Refer to execution_table steps resolving 'posts' and 'title' fields
Concept Snapshot
Single endpoint architecture in GraphQL:
- One URL handles all queries
- Client sends query specifying needed data
- Server parses query, resolves fields
- Fetches only requested data
- Returns combined JSON response
Simplifies API and reduces over-fetching
Full Transcript
In single endpoint architecture for GraphQL, the client sends all requests to one endpoint. The server parses the query to understand what data is requested. It then resolves each field by fetching data from the database or services. After gathering all requested data, the server assembles it into a JSON response and sends it back to the client. This approach simplifies communication by using one endpoint and fetching only the data needed, avoiding multiple URLs and over-fetching.