---
title: "GraphQL Fundamentals: Queries, Mutations & Schema Design"
description: "Master GraphQL foundations: queries, mutations, subscriptions, and schema design."
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/quizzes/post/graphql-fundamentals-quiz
---

# GraphQL Fundamentals: Queries, Mutations & Schema Design

Welcome to the GraphQL Basics Quiz! Mastering GraphQL is essential for building efficient, flexible APIs that empower clients to request exactly what they need. This quiz will test your understanding of core GraphQL concepts like queries, mutations, schema design, and more. Each question is designed to challenge your knowledge and help you solidify your grasp of GraphQL fundamentals. Good luck!

## Questions

### 1. What is the primary difference between GraphQL and REST?

- **GraphQL lets clients request specific fields; REST returns fixed data shapes** ✅
  - GraphQL allows clients to specify which fields to fetch, whereas REST endpoints return predefined data structures.
- GraphQL requires a specific database; REST works with any data storage
  - Both technologies are database-agnostic and can interface with any storage layer.
- GraphQL uses XML for transport; REST relies exclusively on JSON objects
  - Both GraphQL and REST typically use JSON as their primary data transport format.
- GraphQL is a server-side language; REST is a client-side routing library
  - Both are architectural styles/specifications for building and consuming APIs.

**Hint:** Think about what data you request and how you request it.

### 2. In GraphQL, what is a query?

- **A read-only fetch operation used to request specific data from the server** ✅
  - Queries retrieve data. Clients define the shape of the response by specifying fields.
- A write operation used to modify existing records within the database
  - Operations that modify data are called mutations, not queries.
- A persistent connection that pushes real-time updates to the client
  - Real-time data streaming is handled by subscriptions rather than queries.
- A configuration file that defines the relationship between API types
  - The structure of the API is defined by the schema, not by individual queries.

**Hint:** Think about how you ask for data.

### 3. What is the purpose of a GraphQL schema?

- **To define the types, fields, and operations available in the API** ✅
  - The schema acts as a contract between the server and the client, defining the available data.
- To manage the internal caching logic for expensive database calls
  - Caching is an implementation detail usually handled by the client or a middleware layer.
- To encrypt sensitive field data before it is sent over the network
  - Security and encryption are handled by transport protocols like HTTPS, not the schema.
- To automatically generate SQL queries based on client request shapes
  - While tools exist for this, the schema itself only defines the structure of the API.

**Hint:** Think about what defines the structure and capabilities of an API.

### 4. What is a mutation in GraphQL?

- **An operation used to create, update, or delete data on the server** ✅
  - Mutations change server state. Unlike queries, mutations are intended for side effects.
- A validation function that checks if a query is syntactically correct
  - Validation happens automatically against the schema; mutations are for data modification.
- A way to combine multiple query results into a single JSON response
  - Combining results is a standard feature of the execution engine, not specific to mutations.
- A specialized field that handles real-time data streaming via sockets
  - Real-time streaming is the responsibility of the subscription operation type.

**Hint:** Think about modifying data (create, update, delete).

### 5. What is a resolver in GraphQL?

- **A function that populates the data for a specific field in the schema** ✅
  - Resolvers are the "workhorses" that fetch or compute data for every requested field.
- A middleware component that handles user authentication and sessions
  - While resolvers can check auth, their primary role is providing data for fields.
- A tool that resolves naming conflicts between different schema versions
  - GraphQL schemas generally evolve without versioning; resolvers do not manage naming conflicts.
- A client-side library used to normalize and store query results locally
  - Resolvers are server-side functions, whereas normalization is a client-side caching task.

**Hint:** Think about how fields get their values.

### 6. In GraphQL, what is a scalar type?

- **A primitive leaf type representing values like String, Int, or Boolean** ✅
  - Scalars are the fundamental units of data that do not have sub-fields.
- A complex type that groups multiple fields into a single object
  - Types with sub-fields are called Object types, not Scalar types.
- A specialized query used to fetch large datasets in paginated chunks
  - Pagination is a design pattern, not a built-in GraphQL scalar type.
- A directive used to modify the behavior of a specific field or query
  - Directives modify execution; scalars define the nature of the data itself.

**Hint:** Think about primitive data types (strings, numbers, booleans).

### 7. What does "strongly typed" mean in the context of GraphQL?

- **The server validates the query structure against the schema before execution** ✅
  - GraphQL ensures that every field and argument matches the schema types before running.
- The API requires an encrypted connection to ensure data type integrity
  - Encryption relates to security (TLS/SSL), not the type system of the API.
- The system only allows one specific database type to be used as a backend
  - GraphQL can be used with any database, regardless of its underlying type system.
- The API is written in a language like TypeScript or Java for performance
  - Strongly typed refers to the GraphQL schema contract, not the implementation language.

**Hint:** Think about type validation before execution.

### 8. What is a GraphQL fragment used for?

- **To define a reusable set of fields that can be shared across queries** ✅
  - Fragments help keep queries DRY (Don’t Repeat Yourself) by grouping common fields.
- To break a single large query into multiple smaller HTTP requests
  - Fragments are a structural convenience and do not change the number of requests.
- To allow the server to return partial data if a database error occurs
  - Partial data is handled by nullability and error objects, not fragments.
- To provide temporary authorization for specific sensitive fields
  - Authorization is usually handled via context or directives, not fragments.

**Hint:** Think about reusing field selections.

### 9. What is a subscription in GraphQL?

- **An operation that maintains a connection to push real-time data updates** ✅
  - Subscriptions use persistent connections (like WebSockets) to stream data to clients.
- A recurring billing model for users to access premium API endpoints
  - In GraphQL, subscription refers to a technical operation type, not a business model.
- A way for developers to follow updates to the GraphQL documentation
  - Subscriptions are part of the functional API spec for streaming application data.
- A method for caching frequently accessed data on the client device
  - Caching is distinct from the real-time push mechanism provided by subscriptions.

**Hint:** Think about real-time updates when data changes.

### 10. What does the term "N+1 query problem" mean in GraphQL?

- **Fetching a list of items results in one database call for every item** ✅
  - This occurs when a resolver for a list item executes a new database query for every row.
- A security flaw where a single query can bypass N layers of protection
  - The N+1 problem is a performance bottleneck, not a security vulnerability.
- A schema design rule where every object must have at least N+1 fields
  - There are no rules regarding the minimum number of fields in a GraphQL object.
- The maximum number of concurrent connections a single server can handle
  - This refers to server capacity/concurrency, not the N+1 data fetching pattern.

**Hint:** Think about making one query per item causing many database calls.

### 11. In GraphQL, what is an "object type"?

- **A schema type that contains a collection of named fields and their types** ✅
  - Object types are the building blocks of a schema, representing the entities in your API.
- The raw JSON response that the server returns to the client
  - The JSON is the result of the query; the object type is the definition in the schema.
- A specialized input format used exclusively for mutation arguments
  - Input formats are defined as "Input Types," which are distinct from standard Object Types.
- A reference to a specific row within a relational database table
  - Object types represent abstract API data, not necessarily specific database rows.

**Hint:** Think about complex types with multiple fields.

### 12. What is a GraphQL argument?

- **A value passed to a field to customize or filter the data it returns** ✅
  - Arguments allow clients to provide inputs like IDs or limit counts directly to fields.
- A logic error in the schema that prevents the server from starting
  - Errors are referred to as "GraphQLErrors," not arguments.
- A specific type of resolver used to calculate mathematical results
  - Resolvers use arguments to fetch data, but they are not arguments themselves.
- A comment left in the schema to explain complex logic to developers
  - Comments are used for documentation; arguments are functional inputs.

**Hint:** Think about parameters passed to fields.

### 13. What does "introspection" mean in GraphQL?

- **The ability to query the schema itself to learn about its structure** ✅
  - Introspection allows tools to "ask" the API what types and fields are available.
- A performance monitoring tool used to track resolver execution time
  - Performance monitoring is usually called profiling or tracing.
- The process of optimizing database indexes for GraphQL queries
  - Database optimization happens at the storage layer, not via GraphQL introspection.
- A security protocol that hides internal field names from the public
  - Introspection actually reveals field names; hiding them is a security configuration.

**Hint:** Think about querying schema information.

### 14. In GraphQL, what is a "non-null" type?

- **A field that is guaranteed to return a value instead of a null result** ✅
  - Marked with an exclamation point (!), non-null types ensure the field is never empty.
- A data type that can only store numeric values like integers or floats
  - Non-null refers to the presence of data, not whether the data is numeric.
- A validation rule that prevents users from submitting empty forms
  - While it helps with validation, "non-null" is a core part of the type system, not a form rule.
- A field that is hidden from the schema unless a valid token is provided
  - Visibility is controlled by authorization logic, not the non-null type modifier.

**Hint:** Think about fields that must always have a value.

### 15. What is a GraphQL union type?

- **A type that allows a field to return one of several different object types** ✅
  - Unions are used when a field could return different types that do not share an interface.
- A method for merging two different GraphQL APIs into a single endpoint
  - Merging APIs is known as schema stitching or federation, not a union type.
- A field that returns a list of items from multiple database tables
  - Returning lists is handled by List types; unions handle returning different object shapes.
- A specific type of resolver that connects to multiple data sources
  - Resolvers can connect to many sources, but this is an implementation detail, not a type.

**Hint:** Think about fields that can return different types.

### 16. What syntax represents a list of items in a GraphQL schema?

- **Wrapping the type name in square brackets, such as [User]** ✅
  - The square bracket syntax indicates that the field will return an array of that type.
- Placing a plus sign after the field name, such as User+
  - The plus sign is not a valid character for defining types in GraphQL.
- Wrapping the field name in curly braces, such as {User}
  - Curly braces are used to define selection sets in queries, not types in schemas.
- Adding the keyword "List" before the type name, such as List User
  - While some languages use a "List" keyword, GraphQL uses bracket notation.

**Hint:** Think about square brackets in type definitions.

### 17. What is an "input type" in GraphQL?

- **A special type used to pass complex objects as arguments to fields** ✅
  - Input types allow you to pass whole objects (like a user profile) into a mutation or query.
- A field that accepts raw text input from a standard HTML form
  - Input types are schema definitions for structured data, not HTML elements.
- A primitive data type like String or Int used for basic queries
  - Primitive types are called Scalars; Input types are specifically for structured arguments.
- A directive that forces a field to accept only uppercase strings
  - Directives modify behavior, but they do not define the structure of input data.

**Hint:** Think about data structures for mutation arguments.

### 18. What is the difference between a root query and a root mutation?

- **Queries are for fetching data; mutations are for changing data** ✅
  - This clear separation of concerns helps define the intent of the API request.
- Queries are public; mutations require a private administrative key
  - Both operation types can be public or private depending on the API security settings.
- Queries run on the database; mutations run on the local cache
  - Both operations typically interact with the server and its data sources.
- Queries are limited to 10 fields; mutations have no field limit
  - Field limits are determined by server configuration, not the operation type.

**Hint:** Think about read vs. write operations.

### 19. What is a "directive" in GraphQL?

- **A modifier starting with @ that changes how a query is executed** ✅
  - Directives like @skip or @deprecated provide instructions to the GraphQL engine.
- A mandatory header required for every GraphQL request sent
  - Headers are part of the HTTP protocol; directives are part of the GraphQL query syntax.
- A specific type of error returned when a resolver fails to run
  - Resolvers return "errors" or "null" upon failure, not directives.
- A database command used to index fields for faster search results
  - Database indexing happens internally and is not controlled by GraphQL directives.

**Hint:** Think about metadata or modifiers on fields (@ symbol).

### 20. What does the @deprecated directive do?

- **Marks a field as no longer supported to discourage its future use** ✅
  - It allows API developers to evolve the schema without immediately breaking existing clients.
- Immediately deletes a field from the schema so it cannot be seen
  - The field remains functional but is flagged as outdated in introspection tools.
- Encrypts the field data to prevent it from being intercepted
  - Deprecation is about API evolution, not data security or encryption.
- Optimizes the field so it returns data much faster than others
  - Deprecation has no impact on performance; it is purely informational.

**Hint:** Think about marking fields as no longer recommended.

### 21. What is the primary purpose of a "DataLoader"?

- **To batch and memoize data requests to reduce database overhead** ✅
  - DataLoader minimizes the number of database hits by grouping requests for the same data.
- To provide a visual progress bar for long-running API queries
  - DataLoaders work on the server-side to optimize fetching, not for UI feedback.
- To automatically upload files from the client to a cloud storage
  - File uploads are handled by multi-part requests or mutations, not DataLoaders.
- To encrypt data during the transmission between server and client
  - Encryption is handled by the transport layer, not a data fetching utility.

**Hint:** Think about batching database queries to avoid N+1 problems.

### 22. What is a GraphQL "interface" type?

- **An abstract type that defines a set of fields multiple types must implement** ✅
  - Interfaces allow you to query common fields across different object types.
- A graphical user interface used by developers to test their queries
  - This usually refers to tools like GraphiQL or Apollo Studio, not the "Interface" type.
- A connection between the GraphQL server and a third-party REST API
  - This is generally called a data source or an adapter, not a schema interface.
- A configuration setting that enables multi-language support for the API
  - Localization is handled through arguments or headers, not the interface type.

**Hint:** Think about shared fields across multiple types.

### 23. How are variables passed to a GraphQL query?

- **By defining them with a $ prefix and passing values in a JSON object** ✅
  - Using variables makes queries reusable and prevents injection-style issues.
- By hardcoding the values directly into the query string as text
  - While possible, this is considered bad practice and prevents query caching.
- By storing them in the server schema as static global constants
  - Variables are dynamic and provided by the client during the request.
- By appending them to the URL as standard query string parameters
  - While GET requests use the URL, the variables themselves are distinct from the URL structure.

**Hint:** Think about using $ syntax to define parameters.

### 24. What is "query complexity" in GraphQL?

- **A calculation of the resource cost of a query to prevent server abuse** ✅
  - Complexity analysis helps protect against deeply nested, expensive queries.
- A measurement of how many lines of code are in a specific resolver
  - Complexity refers to the execution cost of the query, not the length of the code.
- A rating system used to identify how difficult a query is to write
  - This refers to developer experience, not the technical "query complexity" metric.
- The total number of unique types defined within the entire schema
  - The size of the schema is independent of the complexity of an individual query.

**Hint:** Think about deeply nested queries consuming too many resources.

### 25. What is "rate limiting" in GraphQL?

- **Restricting the number of requests a client can make in a timeframe** ✅
  - Rate limiting protects the API from being overwhelmed by too many requests.
- Slowly decreasing the speed of the API as the database grows larger
  - Rate limiting is a security and stability feature, not a performance degradation.
- Limiting the number of fields a user can see based on their role
  - Restricting field access is called "Field-Level Authorization," not rate limiting.
- Setting a maximum file size for all image uploads via mutations
  - This is a "Payload Limit" or "Upload Limit," distinct from request rate limiting.

**Hint:** Think about preventing abuse from excessive queries.

### 26. What is "schema stitching" in GraphQL?

- **The process of merging multiple underlying APIs into one gateway** ✅
  - It allows developers to present multiple microservices as a single GraphQL schema.
- The act of fixing broken types in a schema after a database update
  - Schema stitching is an architectural pattern, not a bug-fixing process.
- A method for compressing the schema to reduce initial load times
  - Stitching combines APIs; it does not involve data compression or minification.
- The practice of manually writing schema files in a text editor
  - Manual writing is just "Schema Design" or "Schema Definition."

**Hint:** Think about combining multiple GraphQL schemas.

### 27. What is an "enum" type in GraphQL?

- **A special scalar that restricts a field to a fixed set of values** ✅
  - Enums (Enumerated types) ensure that a field only accepts or returns specific constants.
- A dynamic list that automatically expands as more data is added
  - Enums are static and must be updated in the schema definition to change.
- A numeric field that only accepts values between zero and ten
  - Enums are for sets of named constants, not specific numeric ranges.
- A type that combines multiple objects into a single search result
  - Combining multiple objects is usually handled by Union or Interface types.

**Hint:** Think about fields with predefined allowed values.

### 28. When would you use an "alias" in a GraphQL query?

- **To rename the result key of a field to avoid name collisions** ✅
  - Aliases allow you to fetch the same field with different arguments in a single request.
- To hide the real name of a database table from the end user
  - The schema already abstracts the database; aliases are for the JSON response keys.
- To create a temporary shortcut for a very long field name
  - While they can shorten names, their primary purpose is handling multiple instances of a field.
- To assign a nickname to a user within a social media application
  - In GraphQL, an alias is a query syntax feature, not an application data field.

**Hint:** Think about querying the same field multiple times with different results.
