GraphQL interview questions — Medium
298 medium-level GraphQL questions from our API Testing bank, each with the correct answer and an explanation of why it is correct.
What this covers
GraphQL appears throughout API Testing interviews. At medium level, interviewers are typically checking that you have used it in practice: what you configured, what broke, and how you knew it worked. Work through these, then explain your answer out loud; the second part is what interviews actually test.
20 example questions
1. "Guard rejecting overly expensive queries" — in GraphQL, this describes which of the following?
- A. Resolver.
- B. Introspection query.
- C. Query complexity limit.correct
- D. Persisted query.
Why: query complexity limit: Guard rejecting overly expensive queries.
2. "Technique grouping resolver calls to avoid N+1 queries" — in GraphQL, this describes which of the following?
- A. Mutation input type.
- B. Introspection query.
- C. Persisted query.
- D. Batching (dataloader).correct
Why: batching (dataloader): Technique grouping resolver calls to avoid N+1 queries.
3. "Structured object type used as a mutation argument" — in GraphQL, this describes which of the following?
- A. Persisted query.
- B. Query complexity limit.
- C. Mutation input type.correct
- D. Introspection query.
Why: mutation input type: Structured object type used as a mutation argument.
4. "Pre-registered query referenced by hash to reduce payloads" — in GraphQL, this describes which of the following?
- A. Persisted query.correct
- B. Mutation input type.
- C. Introspection query.
- D. Query complexity limit.
Why: persisted query: Pre-registered query referenced by hash to reduce payloads.
5. "Marks a field or argument that can never be null" — in GraphQL, this describes which of the following?
- A. Introspection query.
- B. Non-null modifier (!).correct
- C. Batching (dataloader).
- D. Query complexity limit.
Why: non-null modifier (!): Marks a field or argument that can never be null.
6. "Query that returns the schema itself" — in GraphQL, this describes which of the following?
- A. Introspection query.correct
- B. Non-null modifier (!).
- C. Scalar type.
- D. Persisted query.
Why: introspection query: Query that returns the schema itself.
7. Which of the following statements about GraphQL is TRUE?
- A. Variables parameterize GraphQL operations instead of string concatenation.correct
- B. Mutations in GraphQL are read-only operations.
- C. GraphQL clients cannot choose which fields are returned.
- D. GraphQL schemas cannot be introspected by tools.
Why: Variables prevent injection and improve caching of persisted queries.
8. Identify the accurate statement about GraphQL:
- A. GraphQL responses can return HTTP 200 while containing an errors array in the body.correct
- B. GraphQL requires a separate endpoint URL for every resource like REST.
- C. A GraphQL server always returns HTTP 500 when any field errors occur.
- D. Mutations in GraphQL are read-only operations.
Why: Testing must inspect the errors field, not just the status code.
9. "Leaf type such as Int, String, or Boolean" — in GraphQL, this describes which of the following?
- A. Persisted query.
- B. Non-null modifier (!).
- C. Scalar type.correct
- D. Resolver.
Why: scalar type: Leaf type such as Int, String, or Boolean.
10. "Server function that returns the data for a field" — in GraphQL, this describes which of the following?
- A. Introspection query.
- B. Non-null modifier (!).
- C. Batching (dataloader).
- D. Resolver.correct
Why: resolver: Server function that returns the data for a field.
11. Which statement correctly describes GraphQL?
- A. GraphQL clients cannot choose which fields are returned.
- B. Nested queries can cause performance issues, so depth and complexity limits should be tested.correct
- C. Mutations in GraphQL are read-only operations.
- D. GraphQL schemas cannot be introspected by tools.
Why: Abusive deep queries are a common GraphQL attack vector.
12. In GraphQL, which of the following is described as: "Marks a field or argument that can never be null"?
- A. Resolver.
- B. Query complexity limit.
- C. Mutation input type.
- D. Non-null modifier (!).correct
Why: non-null modifier (!): Marks a field or argument that can never be null.
13. In GraphQL, which of the following is described as: "Pre-registered query referenced by hash to reduce payloads"?
- A. Persisted query.correct
- B. Mutation input type.
- C. Scalar type.
- D. Introspection query.
Why: persisted query: Pre-registered query referenced by hash to reduce payloads.
14. In GraphQL, which of the following is described as: "Technique grouping resolver calls to avoid N+1 queries"?
- A. Resolver.
- B. Persisted query.
- C. Query complexity limit.
- D. Batching (dataloader).correct
Why: batching (dataloader): Technique grouping resolver calls to avoid N+1 queries.
15. In the context of GraphQL, which of the following is a correct statement?
- A. GraphQL clients cannot choose which fields are returned.
- B. GraphQL responses can return HTTP 200 while containing an errors array in the body.correct
- C. GraphQL requires a separate endpoint URL for every resource like REST.
- D. GraphQL schemas cannot be introspected by tools.
Why: Testing must inspect the errors field, not just the status code.
16. Which GraphQL concept matches this description: "Technique grouping resolver calls to avoid N+1 queries"?
- A. Introspection query.
- B. Query complexity limit.
- C. Batching (dataloader).correct
- D. Non-null modifier (!).
Why: batching (dataloader): Technique grouping resolver calls to avoid N+1 queries.
17. In GraphQL, which of the following is described as: "Guard rejecting overly expensive queries"?
- A. Mutation input type.
- B. Query complexity limit.correct
- C. Persisted query.
- D. Batching (dataloader).
Why: query complexity limit: Guard rejecting overly expensive queries.
18. Which GraphQL concept matches this description: "Guard rejecting overly expensive queries"?
- A. Resolver.
- B. Query complexity limit.correct
- C. Introspection query.
- D. Batching (dataloader).
Why: query complexity limit: Guard rejecting overly expensive queries.
19. Which GraphQL concept matches this description: "Pre-registered query referenced by hash to reduce payloads"?
- A. Scalar type.
- B. Introspection query.
- C. Resolver.
- D. Persisted query.correct
Why: persisted query: Pre-registered query referenced by hash to reduce payloads.
20. In GraphQL, which of the following is described as: "Structured object type used as a mutation argument"?
- A. Batching (dataloader).
- B. Resolver.
- C. Mutation input type.correct
- D. Query complexity limit.
Why: mutation input type: Structured object type used as a mutation argument.