0
0
GraphQLquery~10 mins

Connection pooling 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 connection pool with a maximum of 10 connections.

GraphQL
const pool = new Pool({ max: [1] });
Drag options to blanks, or click blank then click option'
A10
B5
C20
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Setting max to 1 limits to a single connection, which is not pooling.
Using too high a number can overload the database.
2fill in blank
medium

Complete the code to acquire a client from the connection pool.

GraphQL
const client = await pool.[1]();
Drag options to blanks, or click blank then click option'
AgetClient
Bconnect
Cacquire
Dopen
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like 'getClient' causes errors.
Forgetting to await the async method leads to unresolved promises.
3fill in blank
hard

Fix the error in releasing the client back to the pool.

GraphQL
client.[1]();
Drag options to blanks, or click blank then click option'
Adisconnect
Bclose
Crelease
Dend
Attempts:
3 left
💡 Hint
Common Mistakes
Calling 'end' closes the connection permanently, defeating pooling.
Forgetting to release causes connection leaks.
4fill in blank
hard

Fill both blanks to create a query using a pooled client and release it after.

GraphQL
const client = await pool.[1]();
const res = await client.query('SELECT * FROM users');
client.[2]();
Drag options to blanks, or click blank then click option'
Aconnect
Brelease
Cend
Ddisconnect
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'end' or 'disconnect' closes the connection permanently.
Not releasing the client causes connection exhaustion.
5fill in blank
hard

Fill all three blanks to configure a pool with max 15 connections, idle timeout 30000 ms, and statement timeout 5000 ms.

GraphQL
const pool = new Pool({ max: [1], idleTimeoutMillis: [2], statement_timeout: [3] });
Drag options to blanks, or click blank then click option'
A15
B30000
C5000
D10000
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up timeout values or using wrong property names.
Setting max too low or too high can cause performance issues.