GraphQL Interview Questions Hindi mein

GraphQL कोर्स के 25 सवाल, हर सवाल के सही जवाब और explanation के साथ। जवाब देखने से पहले ख़ुद सोचें।

GraphQL Foundations

1. What problem does GraphQL address directly?

  1. TLS encryption
  2. Database indexing
  3. Over-fetching and under-fetching of data
  4. Container orchestration
जवाब देखें

जवाब: Over-fetching and under-fetching of data

Clients choose the fields.

पाठ: GraphQL Compared With REST

2. What happens to a query that requests a field not in the schema?

  1. It fails validation before execution
  2. The field is returned as null silently
  3. The server creates the field
  4. Only the HTTP status changes
जवाब देखें

जवाब: It fails validation before execution

The schema is a contract.

पाठ: How a GraphQL Request Works

3. Which is a common trade-off of GraphQL?

  1. It only works with SQL databases
  2. It cannot return nested data
  3. It has no type system
  4. HTTP caching is harder than with resource-oriented URLs
जवाब देखें

जवाब: HTTP caching is harder than with resource-oriented URLs

One endpoint, varied queries.

पाठ: When to Use GraphQL

Designing the Schema

4. What does [Order!]! mean?

  1. An optional list of optional orders
  2. A non-null list whose items are non-null orders
  3. Exactly one order
  4. A map of orders
जवाब देखें

जवाब: A non-null list whose items are non-null orders

Both the list and its items are non-null.

पाठ: Object Types, Scalars and Nullability

5. How are multiple mutation fields in one request executed?

  1. In parallel, in random order
  2. Serially, in the order written
  3. Only the first runs
  4. They are rejected
जवाब देखें

जवाब: Serially, in the order written

Query fields may run in parallel; mutations run in order.

पाठ: Query, Mutation and Subscription Types

6. Which type describes structured arguments to a mutation?

  1. A subscription
  2. A union
  3. An interface
  4. An input type
जवाब देखें

जवाब: An input type

Inputs are separate from output types.

पाठ: Enums, Interfaces, Unions and Inputs

Writing Queries

7. Why use an alias?

  1. To request the same field more than once with different arguments
  2. To make a field optional
  3. To delete a field
  4. To change its type
जवाब देखें

जवाब: To request the same field more than once with different arguments

Response keys must be unique.

पाठ: Fields, Aliases and Fragments

8. Where are variable values sent?

  1. In the HTTP path
  2. Inside the field names
  3. In a separate variables JSON object alongside the query
  4. In a cookie
जवाब देखें

जवाब: In a separate variables JSON object alongside the query

Static query text, dynamic variables.

पाठ: Variables and Directives

9. What does introspection provide?

  1. Server CPU usage
  2. Database statistics
  3. A description of the schema's types and fields, queried through GraphQL itself
  4. User passwords
जवाब देखें

जवाब: A description of the schema's types and fields, queried through GraphQL itself

Powers tooling and docs.

पाठ: Introspection and Tooling

Mutations, Errors and Subscriptions

10. Why return the modified object in a mutation payload?

  1. So clients can update their caches without another request
  2. Because GraphQL requires exactly one field
  3. To slow down attackers
  4. To avoid using variables
जवाब देखें

जवाब: So clients can update their caches without another request

Caches normalise by id.

पाठ: Designing Mutations

11. Where should an expected "coupon expired" error usually be modelled?

  1. As a stack trace in the response
  2. As an HTTP 500
  3. Only in server logs
  4. In the schema, for example as userErrors or a union result type
जवाब देखें

जवाब: In the schema, for example as userErrors or a union result type

Expected errors are data.

पाठ: Error Handling

12. Which transport is commonly used for GraphQL subscriptions?

  1. FTP
  2. WebSockets
  3. SMTP
  4. Plain HTTP GET without streaming
जवाब देखें

जवाब: WebSockets

Long-lived, two-way connections.

पाठ: Subscriptions

Building a GraphQL Server

13. What is the first argument passed to a field resolver?

  1. The HTTP request
  2. The parent object (the result of the enclosing field)
  3. The database connection
  4. The schema
जवाब देखें

जवाब: The parent object (the result of the enclosing field)

parent, args, context, info.

पाठ: Resolvers

14. Why is authorising only root fields insufficient in GraphQL?

  1. GraphQL has no authentication
  2. Root fields cannot have resolvers
  3. Context is not available in nested fields
  4. The same data can be reached through many nested paths
जवाब देखें

जवाब: The same data can be reached through many nested paths

Protect data where it is resolved.

पाठ: Context and Authorisation

15. What does DataLoader do?

  1. Batches many individual loads into one call and caches them per request
  2. Encrypts queries
  3. Generates the schema
  4. Replaces the database
जवाब देखें

जवाब: Batches many individual loads into one call and caches them per request

Fixes N+1 queries.

पाठ: Solving N+1 With DataLoader

Using GraphQL From Clients

16. What must a client check even when the HTTP status is 200?

  1. The cookie expiry
  2. The Content-Length only
  3. The errors array in the response body
  4. Nothing else
जवाब देखें

जवाब: The errors array in the response body

Partial errors are common.

पाठ: Calling GraphQL With fetch

17. How does a normalised cache identify objects?

  1. By the time of the request
  2. By query text only
  3. By type name and id
  4. By the HTTP method
जवाब देखें

जवाब: By type name and id

One copy per object.

पाठ: Client Caching Libraries

18. What does GraphQL code generation provide?

  1. Typed results and variables for operations, derived from the schema
  2. A new database
  3. Faster networks
  4. Automatic authentication
जवाब देखें

जवाब: Typed results and variables for operations, derived from the schema

Compile-time safety.

पाठ: Code Generation and Typed Operations

Pagination, Limits and Caching

19. What does a client pass to get the next page in cursor pagination?

  1. Nothing; pages are automatic
  2. page: 2
  3. The full previous result
  4. after: the endCursor from the previous page
जवाब देखें

जवाब: after: the endCursor from the previous page

Opaque cursors mark positions.

पाठ: Cursor-Based Pagination

20. What do persisted queries allow a server to do?

  1. Skip the schema entirely
  2. Accept only pre-registered operations, identified by hash or ID
  3. Store user passwords
  4. Disable resolvers
जवाब देखें

जवाब: Accept only pre-registered operations, identified by hash or ID

An allow-list of queries.

पाठ: Query Cost, Depth Limits and Persisted Queries

21. Why is HTTP caching harder for GraphQL than for REST?

  1. GraphQL responses are binary
  2. Many different queries share one endpoint, often sent with POST
  3. GraphQL forbids caching
  4. Browsers do not support GraphQL
जवाब देखें

जवाब: Many different queries share one endpoint, often sent with POST

Use GET, persisted queries and hints.

पाठ: Caching Strategies

GraphQL in Production

22. Which risk is particularly associated with GraphQL?

  1. Inability to authenticate
  2. Missing TLS by design
  3. Lack of a type system
  4. Denial of service through deeply nested or very expensive queries
जवाब देखें

जवाब: Denial of service through deeply nested or very expensive queries

Clients compose arbitrary queries.

पाठ: GraphQL Security

23. Which schema change is non-breaking?

  1. Adding a new optional field
  2. Removing a field
  3. Renaming a field
  4. Changing a field from String to Int
जवाब देखें

जवाब: Adding a new optional field

Existing queries are unaffected.

पाठ: Evolving the Schema

24. What does a federation router do?

  1. Replaces resolvers in every service
  2. Stores all data centrally
  3. Composes subgraphs into one schema and plans queries across them
  4. Generates REST endpoints
जवाब देखें

जवाब: Composes subgraphs into one schema and plans queries across them

One graph, many services.

पाठ: Federation and Composing Services

25. Which belongs on a GraphQL API checklist?

  1. Authorisation only on root fields
  2. Unbounded lists for convenience
  3. Lists use cursor pagination with a maximum page size
  4. Removing fields without deprecation
जवाब देखें

जवाब: Lists use cursor pagination with a maximum page size

Predictable, safe APIs.

पाठ: A GraphQL API Checklist

← कोर्स पर वापस जाएँ