0
0
GraphQLquery~10 mins

Gateway composition in GraphQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a basic gateway that composes two services.

GraphQL
const gateway = new ApolloGateway({ serviceList: [[1]] });
Drag options to blanks, or click blank then click option'
A{ name: 'users', url: 'http://localhost:4001/graphql' }, { name: 'products', url: 'http://localhost:4002/graphql' }
B'users'
C{ name: 'users', url: 'http://localhost:4001/graphql' }
D['users', 'products']
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a single object instead of an array.
Using just service names as strings without URLs.
2fill in blank
medium

Complete the code to start the Apollo Gateway server on port 4000.

GraphQL
gateway.listen({ port: [1] }).then(({ url }) => { console.log(`Gateway ready at ${url}`); });
Drag options to blanks, or click blank then click option'
A5000
B4000
C8080
D3000
Attempts:
3 left
💡 Hint
Common Mistakes
Using the port of one of the underlying services instead of the gateway port.
3fill in blank
hard

Fix the error in the service list by completing the missing key.

GraphQL
const serviceList = [{ [1]: 'users', url: 'http://localhost:4001/graphql' }];
Drag options to blanks, or click blank then click option'
AserviceName
Bendpoint
Cname
Dtype
Attempts:
3 left
💡 Hint
Common Mistakes
Using endpoint or serviceName instead of name.
4fill in blank
hard

Fill both blanks to create a gateway that composes two services and logs the URL when ready.

GraphQL
const gateway = new ApolloGateway({ serviceList: [1] });
gateway.listen().then(({ [2] }) => console.log(`Gateway running at ${url}`));
Drag options to blanks, or click blank then click option'
A[{ name: 'accounts', url: 'http://localhost:4003/graphql' }, { name: 'reviews', url: 'http://localhost:4004/graphql' }]
Burl
Caddress
Dendpoint
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like address or endpoint.
Passing a single service object instead of an array.
5fill in blank
hard

Fill all three blanks to define a gateway with three services and start it on port 5000.

GraphQL
const gateway = new ApolloGateway({ serviceList: [1] });
gateway.listen({ port: [2] }).then(({ [3] }) => console.log(`Gateway ready at ${url}`));
Drag options to blanks, or click blank then click option'
A[{ name: 'users', url: 'http://localhost:4001/graphql' }, { name: 'products', url: 'http://localhost:4002/graphql' }, { name: 'orders', url: 'http://localhost:4005/graphql' }]
B5000
Curl
Dendpoint
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong port numbers or property names.
Not passing an array for the service list.