← Back to list

Top 100 GraphQL Interview Questions with 1 liner Answers

Basic GraphQL Concepts

Sam Atmaramani · 2025-07-14 05:57 · 21 claps · 7.0 min read
#graphql #graphql-federation #interview-questions
Open on Medium ↗

Top 100 GraphQL Interview Questions with 1 liner Answers

Basic GraphQL Concepts

Q1. What is GraphQL?

Answer: A query language for APIs that allows clients to request exactly the data they need.

Q2. How is GraphQL different from REST?

Answer: Unlike REST, GraphQL lets clients query multiple resources in a single request.

Q3. What are the main components of a GraphQL operation?

Answer: Queries, mutations, and subscriptions.

Q4. What is a query in GraphQL?

Answer: It’s used to fetch data from the server.

Q5. What is a mutation in GraphQL?

Answer: It is used to modify server-side data.

Q6. What is a subscription in GraphQL?

Answer: It enables real-time data updates over WebSocket.

Q7. What is a resolver in GraphQL?

Answer: A function that resolves a value for a type or field in a schema.

Q8. What is the GraphQL schema?

Answer: A schema defines types, queries, and mutations of the API.

Q9. What is a scalar type in GraphQL?

Answer: A primitive data type like Int, Float, String, Boolean, and ID.

Q10. What is a custom scalar?

Answer: A user-defined scalar for data like Date or URL.

Intermediate GraphQL Topics

Q11. What is a fragment in GraphQL?

Answer: Reusable unit of query fields.

Q12. Can we alias fields in GraphQL?

Answer: Yes, aliases rename the result fields.

Example:

{ user1: user(id: 1) { name } user2: user(id: 2) { name } }

Q13. What is introspection in GraphQL?

Answer: A feature to query the schema itself.

Q14. What is the purpose of __typename?

Answer: It returns the type name of the object for polymorphic queries.

Q15. What are directives in GraphQL?

Answer: Instructions like @include and @skip to control query behavior.

Q16. What is the use of @include?

Answer: Conditionally includes fields based on a variable.

Q17. Can GraphQL handle versioning?

Answer: Versioning is handled through schema evolution, not versioned endpoints.

Q18. What is schema stitching?

Answer: Combines multiple GraphQL schemas into one.

Q19. How are errors handled in GraphQL?

Answer: Returned in an errors array in the response.

Q20. What is batching in GraphQL?

Answer: Sending multiple operations in a single HTTP request.

Advanced GraphQL Questions

Q21. How does GraphQL avoid over-fetching?

Answer: Clients specify exactly which fields they need.

Q22. What is over-fetching and under-fetching?

Answer: Over-fetching gets unnecessary data; under-fetching gets too little.

Q23. What is a union type in GraphQL?

Answer: A type that can return multiple object types.

Q24. How do you handle nested resolvers efficiently?

Answer: Use data loaders to batch and cache DB requests.

Q25. What is a data loader?

Answer: A utility to reduce redundant database queries.

Q26. What is nullability in GraphQL?

Answer: Indicates if a field can return null.

Q27. What’s the difference between nullable and non-nullable types?

Answer: Non-nullable types throw errors if no data is returned.

Q28. Can GraphQL use HTTP GET?

Answer: Yes, for queries; mutations typically use POST.

Q29. What is persisted query?

Answer: A pre-stored query sent with a hash to reduce payload size.

Q30. How to secure GraphQL APIs?

Answer: Use authentication, authorization, rate limiting, and depth limiting.

Q31. What are input types in GraphQL?

Answer: Input types define complex objects for passing into queries or mutations.

Q32. What is type inference in GraphQL?

Answer: GraphQL doesn’t do type inference; all types must be explicitly declared.

Q33. What is an enum in GraphQL?

Answer: A custom scalar that restricts values to a fixed set.

Q34. How does GraphQL support pagination?

Answer: Using first, last, before, and after or offset/limit conventions.

Q35. What are connections in GraphQL?

Answer: A pattern used for implementing pagination.

Q36. How do you handle file uploads in GraphQL?

Answer: Using multipart/form-data with libraries like graphql-upload.

Q37. What are common GraphQL client libraries?

Answer: Apollo Client, Relay, URQL.

Q38. What is Relay?

Answer: A GraphQL client by Facebook with strong conventions and tooling.

Q39. What is Apollo Client?

Answer: A flexible GraphQL client supporting caching, subscriptions, and more.

Q40. Can GraphQL return partial data?

Answer: Yes, it returns available data and lists errors separately.

Q41. What is field-level authorization?

Answer: Restricting access to specific fields based on user roles.

Q42. How to log requests in GraphQL?

Answer: Use middleware in the GraphQL server for logging context and queries.

Q43. What is depth limiting in GraphQL?

Answer: Prevents deeply nested queries that can overload the server.

Q44. How to rate limit GraphQL APIs?

Answer: Use request metadata like IPs or tokens to limit requests.

Q45. What is query complexity analysis?

Answer: Estimating cost of query execution to prevent abuse.

Q46. How to test GraphQL APIs?

Answer: Use tools like Postman, GraphiQL, Apollo Studio, and unit tests.

Q47. What tools are used to document GraphQL?

Answer: GraphiQL, GraphQL Voyager, and schema introspection.

Q48. What is schema-first design?

Answer: You write the GraphQL schema before implementing resolvers.

Q49. What is code-first design?

Answer: Schema is auto-generated from code using decorators or classes.

Q50. What’s the difference between SDL and executable schema?

Answer: SDL is a string definition; executable schema has resolver logic attached.

Q51. Can GraphQL work with SQL databases?

Answer: Yes, using resolvers and ORMs like Prisma.

Q52. How does GraphQL support mobile apps?

Answer: It reduces payload and improves performance with tailored responses.

Q53. Can you use GraphQL with microservices?

Answer: Yes, using schema stitching or federation.

Q54. What is mocking in GraphQL?

Answer: Returning fake data for testing or development.

Q55. What is a schema directive?

Answer: A way to add behavior or transform schema types.

Q56. How do you version GraphQL schema changes?

Answer: Use deprecation, schema validation, and client coordination.

Q57. What is @deprecated in GraphQL?

Answer: A directive to mark fields as outdated with a reason.

Q58. What is @skip directive?

Answer: Skips a field from the response based on a condition.

Q59. Can GraphQL be used with REST APIs?

Answer: Yes, as a wrapper over REST endpoints.

Q60. What’s a GraphQL mesh?

Answer: It unifies APIs (REST, SOAP, GraphQL) into a single GraphQL endpoint.

Q61. How does GraphQL support DevOps?

Answer: Easier monitoring, versioning, and deployment with static typing.

Q62. What are some production GraphQL tools?

Answer: Apollo Studio, Hasura, GraphQL Inspector, Prisma.

Q63. What is caching in GraphQL clients?

Answer: Storing previous responses to avoid redundant queries.

Q64. How do you invalidate a cache in GraphQL?

Answer: Use client-side policies or server-side headers.

Q65. What is optimistic UI update in GraphQL?

Answer: Temporarily assumes mutation success to update UI instantly.

Q66. What is schema delegation?

Answer: A way to forward queries from one schema to another.

Q67. Can GraphQL APIs be introspected in production?

Answer: Usually disabled in prod to prevent schema leaks.

Q68. What is GraphQL Yoga?

Answer: A full-featured GraphQL server built on top of Envelop and Express.

Q69. What is GraphQL Shield?

Answer: Middleware for permissions and access control in GraphQL.

Q70. How do you monitor GraphQL performance?

Answer: Use tools like Apollo Studio, Prometheus, or built-in metrics.

GraphQL Federation-Specific 30 Questions from 71 to 100

Q71. What is GraphQL Federation?

Answer: A way to compose multiple GraphQL services into a single schema.

Q72. What is a federated schema?

Answer: A schema built by composing multiple subgraphs.

Q73. What is a subgraph in federation?

Answer: A GraphQL service that provides part of the schema.

Q74. What is Apollo Gateway?

Answer: A service that acts as a unified entry point for federated schemas.

Q75. What is the @key directive?

Answer: Defines a primary key to reference and extend types across services.

Q76. What is the @extends directive?

Answer: Used in subgraphs to extend types from other subgraphs.

Q77. How is schema composition done in federation?

Answer: Subgraphs are registered with the gateway which composes them.

Q78. Can you share context between federated services?

Answer: Yes, via headers or custom context passing through the gateway.

Q79. How do you debug errors in federated services?

Answer: Use Apollo Studio, error extensions, and proper logging.

Q80. What is the role of @requires directive?

Answer: Specifies fields required from the base type to compute a value.

Q81. What is a gateway in GraphQL Federation?

Answer: It’s the central service that combines and routes requests to subgraphs.

Q82. What is a subgraph in Federation?

Answer: A GraphQL service that provides a portion of the overall schema.

Q83. How do you define entities in a federated service?

Answer: Use the @key directive to uniquely identify the type across services.

Q84. What is the role of @key directive in Federation?

Answer: It defines how a type can be resolved across services.

Q85. Can a type exist in multiple subgraphs?

Answer: Yes, with the help of @extends and @external directives.

Q86. What is @extends in Federation?

Answer: Indicates a type is being extended from another subgraph.

Q87. What does @external mean in Federation?

Answer: Marks fields from another service needed to resolve types.

Q88. How are resolvers written in Federation?

Answer: Subgraphs write resolvers normally; gateway handles merging.

Q89. What is the composition step in Federation?

Answer: The process of merging subgraph schemas into a single gateway schema.

Q90. How do errors propagate in Federation?

Answer: Errors from subgraphs are aggregated and returned by the gateway.

Q91. What is Apollo Federation 2.0?

Answer: A newer spec with features like @shareable, improved type merging.

Q92. What is @shareable in Federation 2.0?

Answer: Allows fields to be resolved by multiple subgraphs.

Q93. How to manage authentication in Federation?

Answer: Handle auth in gateway or pass auth context to subgraphs.

Q94. Can we deploy subgraphs independently?

Answer: Yes, that’s one of the core benefits of Federation.

Q95. What is a federated trace?

Answer: It’s the telemetry of request resolution across subgraphs.

Q96. How do you handle versioning in Federation?

Answer: Using schema registries, deprecation, and breaking change detection.

Q97. Can subscriptions be federated?

Answer: Not natively; needs custom implementation or separate handling.

Q98. What is the @requires directive?

Answer: Declares fields needed to compute a field from another subgraph.

Q99. What does @provides do in Federation?

Answer: Specifies fields made available to the gateway for downstream resolution.

Q100. How to test federated services?

Answer: Use Apollo Rover CLI, schema checks, and mock gateways.

Feel free to follow me at below social handles

My LinkedIn Profile https://www.linkedin.com/in/sampurna/ My youTube Channel https://www.youtube.com/@techysam-bl9mk/videos My Udemy Tutorial link https://www.udemy.com/courses/search/?src=ukw&q=sampurna+atmaramani My Github Link https://github.com/satmaramani My Own Npm Packages https://www.npmjs.com/~s.atmaramani


메타데이터
post_id
02bfa730006a
slug
top-100-graphql-interview-questions-with-answers-02bfa730006a
url
https://medium.com/@s.atmaramani/top-100-graphql-interview-questions-with-answers-02bfa730006a
canonical_url
https://medium.com/@s.atmaramani/top-100-graphql-interview-questions-with-answers-02bfa730006a
author_url
https://medium.com/@s.atmaramani
status
ok
fetched_at
2026-07-20 21:08:49