Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is Gateway Composition in GraphQL?
Gateway Composition is a method to combine multiple GraphQL services into one unified API, allowing clients to query data from different sources through a single endpoint.
Click to reveal answer
beginner
How does Gateway Composition improve client experience?
It simplifies client requests by providing a single GraphQL endpoint that aggregates data from multiple services, so clients don't need to manage multiple APIs separately.
Click to reveal answer
intermediate
What role does a Gateway play in Gateway Composition?
The Gateway acts as a central server that receives client queries, splits them into sub-queries for different services, then combines the results into one response.
Click to reveal answer
intermediate
Name one challenge Gateway Composition helps to solve.
It helps solve the problem of data fragmentation by merging multiple GraphQL schemas into a single schema, making data access easier and more consistent.
Click to reveal answer
advanced
What is a key difference between Gateway Composition and schema stitching?
Gateway Composition focuses on composing multiple GraphQL services at runtime with a gateway, while schema stitching merges schemas statically before serving them.
Click to reveal answer
What does a GraphQL Gateway do in Gateway Composition?
ACombines multiple GraphQL services into one API
BStores data for all services
CReplaces all backend services
DOnly handles authentication
✗ Incorrect
The Gateway combines multiple GraphQL services into a single API endpoint for clients.
Which benefit does Gateway Composition provide to clients?
AMultiple endpoints to query
BSingle endpoint for all data
CNo need for queries
DDirect database access
✗ Incorrect
Clients use a single endpoint to access data from multiple services.
Gateway Composition typically involves:
ADeleting unused services
BUsing only one database
CReplacing REST APIs
DMerging schemas at runtime
✗ Incorrect
Gateway Composition merges multiple GraphQL schemas dynamically at runtime.
Which is NOT a function of the Gateway in Gateway Composition?
AServing as a single API endpoint
BCombining service responses
CStoring all client data permanently
DSplitting queries to services
✗ Incorrect
The Gateway does not store client data permanently; it routes and combines queries and responses.
Gateway Composition helps to:
ASimplify data access
BIncrease client complexity
CFragment client queries
DRemove GraphQL schemas
✗ Incorrect
It simplifies data access by unifying multiple services under one API.
Explain what Gateway Composition is and why it is useful in GraphQL.
Think about how multiple data sources can be accessed easily by clients.
You got /4 concepts.
Describe the role of the Gateway in Gateway Composition and how it handles client queries.
Focus on the Gateway's job as a middleman between clients and services.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of gateway composition in GraphQL?
easy
A. To combine multiple GraphQL services into a single API endpoint
B. To create multiple endpoints for each service
C. To replace GraphQL with REST APIs
D. To disable client requests
Solution
Step 1: Understand gateway composition
Gateway composition merges several GraphQL services into one unified API.
Step 2: Identify the main benefit
This allows clients to send requests to a single endpoint instead of multiple services.
Final Answer:
To combine multiple GraphQL services into a single API endpoint -> Option A
Quick Check:
Gateway composition = single API endpoint [OK]
Hint: Gateway composition means one API endpoint for many services [OK]
Common Mistakes:
Thinking it creates multiple endpoints
Confusing with REST APIs
Believing it disables client requests
2. Which of the following is the correct way to initialize ApolloGateway with two services named 'users' and 'products'?
easy
A. ApolloGateway({ services: ['users', 'products'] })
B. new ApolloGateway(services: ['users', 'products'])
C. new ApolloGateway({ services: [{ name: 'users', url: 'http://users' }, { name: 'products', url: 'http://products' }] })
D. new ApolloGateway({ endpoints: ['users', 'products'] })
ApolloGateway expects an object with a 'services' array containing objects with 'name' and 'url'.
Step 2: Match the correct syntax
new ApolloGateway({ services: [{ name: 'users', url: 'http://users' }, { name: 'products', url: 'http://products' }] }) correctly uses new ApolloGateway with services array of objects including name and url.
Final Answer:
new ApolloGateway({ services: [{ name: 'users', url: 'http://users' }, { name: 'products', url: 'http://products' }] }) -> Option C
Quick Check:
ApolloGateway needs services array with name and url [OK]
Hint: Use services array with name and url objects in ApolloGateway [OK]