Complete the code to set the maximum query depth to 3.
const server = new ApolloServer({ schema, validationRules: [depthLimit({ maxDepth: [1] })] });The maxDepth option limits the query depth. Setting it to 3 restricts queries to a depth of 3.
Complete the code to import the depthLimit function from the correct package.
import [1] from 'graphql-depth-limit';
The package graphql-depth-limit exports the function depthLimit which is used to limit query depth.
Fix the error in the validationRules array to correctly apply depth limiting.
const server = new ApolloServer({ schema, validationRules: [[1]] });The depthLimit function must be called with an options object specifying maxDepth. Passing just the function or wrong arguments causes errors.
Fill both blanks to create a validation rule that limits depth to 4 and logs a warning on violation.
const depthLimitRule = depthLimit({ maxDepth: [1], onError: (err) => console.[2]('Depth limit exceeded:', err) });Setting maxDepth to 4 limits queries to depth 4. Using console.warn logs a warning message when the limit is exceeded.
Fill all three blanks to define a GraphQL server with depth limiting set to 2, using the imported depthLimit function and applying it in validationRules.
import [1] from 'graphql-depth-limit'; const server = new ApolloServer({ schema, validationRules: [[2]([3])] });
The function depthLimit is imported and called with an options object { maxDepth: 2 } inside validationRules to enforce depth limiting.