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. "Marks a field or argument that can never be null" — in GraphQL, this describes which of the following?
- A. Non-null modifier (!).correct
- B. Scalar type.
- C. Resolver.
- D. Batching (dataloader).
Why: non-null modifier (!): Marks a field or argument that can never be null.
2. "Technique grouping resolver calls to avoid N+1 queries" — in GraphQL, this describes which of the following?
- A. Resolver.
- B. Introspection query.
- C. Batching (dataloader).correct
- D. Scalar type.
Why: batching (dataloader): Technique grouping resolver calls to avoid N+1 queries.
3. "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.
4. "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.
5. "Pre-registered query referenced by hash to reduce payloads" — in GraphQL, this describes which of the following?
- A. Introspection query.
- B. Mutation input type.
- C. Non-null modifier (!).
- D. Persisted query.correct
Why: persisted query: Pre-registered query referenced by hash to reduce payloads.
6. "Server function that returns the data for a field" — in GraphQL, this describes which of the following?
- A. Non-null modifier (!).
- B. Resolver.correct
- C. Mutation input type.
- D. Scalar type.
Why: resolver: Server function that returns the data for a field.
7. "Leaf type such as Int, String, or Boolean" — in GraphQL, this describes which of the following?
- A. Scalar type.correct
- B. Resolver.
- C. Mutation input type.
- D. Introspection query.
Why: scalar type: Leaf type such as Int, String, or Boolean.
8. Identify the accurate statement about GraphQL:
- A. Mutations in GraphQL are read-only operations.
- B. Subscriptions are used for one-time data fetches only.
- C. GraphQL schemas cannot be introspected by tools.
- D. Variables parameterize GraphQL operations instead of string concatenation.correct
Why: Variables prevent injection and improve caching of persisted queries.
9. "Query that returns the schema itself" — in GraphQL, this describes which of the following?
- A. Batching (dataloader).
- B. Resolver.
- C. Query complexity limit.
- D. Introspection query.correct
Why: introspection query: Query that returns the schema itself.
10. Which of the following statements about GraphQL is TRUE?
- A. GraphQL clients cannot choose which fields are returned.
- B. Mutations in GraphQL are read-only operations.
- C. Subscriptions are used for one-time data fetches only.
- D. GraphQL responses can return HTTP 200 while containing an errors array in the body.correct
Why: Testing must inspect the errors field, not just the status code.
11. Which statement correctly describes GraphQL?
- A. Subscriptions are used for one-time data fetches only.
- B. Mutations in GraphQL are read-only operations.
- C. Variables parameterize GraphQL operations instead of string concatenation.correct
- D. A GraphQL server always returns HTTP 500 when any field errors occur.
Why: Variables prevent injection and improve caching of persisted queries.
12. Which GraphQL concept matches this description: "Marks a field or argument that can never be null"?
- A. Scalar type.
- B. Query complexity limit.
- C. Persisted query.
- D. Non-null modifier (!).correct
Why: non-null modifier (!): Marks a field or argument that can never be null.
13. Which GraphQL concept matches this description: "Technique grouping resolver calls to avoid N+1 queries"?
- A. Resolver.
- B. Batching (dataloader).correct
- C. Mutation input type.
- D. Non-null modifier (!).
Why: batching (dataloader): Technique grouping resolver calls to avoid N+1 queries.
14. In GraphQL, which of the following is described as: "Marks a field or argument that can never be null"?
- A. Batching (dataloader).
- B. Resolver.
- C. Non-null modifier (!).correct
- D. Query complexity limit.
Why: non-null modifier (!): Marks a field or argument that can never be null.
15. In GraphQL, which of the following is described as: "Technique grouping resolver calls to avoid N+1 queries"?
- A. Batching (dataloader).correct
- B. Introspection query.
- C. Non-null modifier (!).
- D. Resolver.
Why: batching (dataloader): Technique grouping resolver calls to avoid N+1 queries.
16. In the context of GraphQL, which of the following is a correct statement?
- A. GraphQL responses can return HTTP 200 while containing an errors array in the body.correct
- B. Subscriptions are used for one-time data fetches only.
- C. GraphQL clients cannot choose which fields are returned.
- D. GraphQL requires a separate endpoint URL for every resource like REST.
Why: Testing must inspect the errors field, not just the status code.
17. In GraphQL, which of the following is described as: "Structured object type used as a mutation argument"?
- A. Mutation input type.correct
- B. Query complexity limit.
- C. Introspection query.
- D. Non-null modifier (!).
Why: mutation input type: Structured object type used as a mutation argument.
18. In GraphQL, which of the following is described as: "Guard rejecting overly expensive queries"?
- A. Scalar type.
- B. Query complexity limit.correct
- C. Resolver.
- D. Batching (dataloader).
Why: query complexity limit: Guard rejecting overly expensive queries.
19. Which GraphQL concept matches this description: "Structured object type used as a mutation argument"?
- A. Query complexity limit.
- B. Non-null modifier (!).
- C. Persisted query.
- D. Mutation input type.correct
Why: mutation input type: Structured object type used as a mutation argument.
20. In GraphQL, which of the following is described as: "Pre-registered query referenced by hash to reduce payloads"?
- A. Mutation input type.
- B. Introspection query.
- C. Persisted query.correct
- D. Query complexity limit.
Why: persisted query: Pre-registered query referenced by hash to reduce payloads.