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 GraphQL introspection?
GraphQL introspection is a feature that lets clients ask a GraphQL server about its schema, types, and queries it supports. It helps tools and developers explore the API.
Click to reveal answer
intermediate
Why might you want to control or disable introspection in GraphQL?
To improve security by hiding schema details from unauthorized users, reducing attack surface, and preventing exposure of sensitive API structure.
Click to reveal answer
intermediate
How can you disable introspection in a GraphQL server?
You can disable introspection by intercepting introspection queries and returning errors or empty results, or by configuring server settings to block introspection queries.
Click to reveal answer
beginner
What is a common introspection query in GraphQL?
A common introspection query is one that asks for __schema or __type fields to get details about the schema, types, fields, and directives supported by the server.
Click to reveal answer
advanced
What is a safe way to allow introspection only for authorized users?
Implement authentication and authorization checks in the server to allow introspection queries only if the user has proper permissions, otherwise block or deny introspection.
Click to reveal answer
What does GraphQL introspection allow you to do?
AAsk the server about its schema and types
BModify the database directly
CEncrypt the API data
DAutomatically generate client code
✗ Incorrect
Introspection lets clients query the server for schema details, not modify data or encrypt it.
Hint: Use boolean false, not strings or other keys [OK]
Common Mistakes:
Using assignment (=) instead of colon (:)
Using string values instead of boolean
Using incorrect option names like disableIntrospection
3. Given this GraphQL server config snippet:
const server = new ApolloServer({
typeDefs,
resolvers,
introspection: false
});
What will happen if a client sends an introspection query?
medium
A. The server will return an error or empty response
B. The server will respond with the full schema details
C. The server will ignore the introspection query and respond normally
D. The server will crash due to unsupported query
Solution
Step 1: Understand the effect of introspection: false
This setting disables introspection queries, so the server blocks schema queries.
Step 2: Predict server response to introspection query
The server will reject the introspection query, usually returning an error or empty result.
Final Answer:
The server will return an error or empty response -> Option A
Quick Check:
introspection: false blocks schema queries [OK]
Hint: introspection false means introspection queries fail [OK]
Common Mistakes:
Thinking server still returns schema data
Assuming server crashes on introspection query
Believing server ignores introspection queries silently
4. You wrote this server setup:
const server = new ApolloServer({
typeDefs,
resolvers,
introspection: 'false'
});
Why does introspection control not work as expected?
medium
A. Because ApolloServer does not support introspection control
B. Because introspection must be set to true to disable it
C. Because introspection expects a boolean, not a string
D. Because typeDefs is missing introspection schema
Solution
Step 1: Check the data type of the introspection option
The option should be a boolean (true or false), not a string.
Step 2: Identify why using a string causes failure
Using 'false' as a string is truthy in JavaScript, so introspection remains enabled.
Final Answer:
Because introspection expects a boolean, not a string -> Option C
Quick Check:
introspection must be boolean, not string [OK]
Hint: Use true/false without quotes for boolean options [OK]
Common Mistakes:
Using string 'false' instead of boolean false
Thinking introspection must be true to disable
Assuming ApolloServer lacks introspection control
5. You want to improve API security by disabling introspection only in production but keep it enabled in development. Which code snippet correctly implements this?
hard
A. const server = new ApolloServer({ typeDefs, resolvers, introspection: process.env.NODE_ENV !== 'production' });
B. const server = new ApolloServer({ typeDefs, resolvers, introspection: process.env.NODE_ENV === 'production' });
C. const server = new ApolloServer({ typeDefs, resolvers, introspection: false });
D. const server = new ApolloServer({ typeDefs, resolvers, introspection: true });
Solution
Step 1: Understand the goal
Disable introspection in production, enable in development.
Step 2: Analyze each option's logic
const server = new ApolloServer({ typeDefs, resolvers, introspection: process.env.NODE_ENV !== 'production' }); sets introspection to true when not in production, false in production, matching the goal.
Final Answer:
const server = new ApolloServer({ typeDefs, resolvers, introspection: process.env.NODE_ENV !== 'production' }); -> Option A
Quick Check:
introspection enabled only if not production [OK]
Hint: Use environment check with !== 'production' for introspection [OK]
Common Mistakes:
Using === 'production' enables introspection in production
Always setting introspection true or false ignores environment
Confusing production and development environment logic