Skip to content
>_ StartupJobList_

Interview questions · Worked answers

GraphQL interview questions and production answers

A strong GraphQL answer treats the schema as a client contract and then follows one operation through validation, authorization, resolver work, partial failure and delivery. It explains both what the specification guarantees and what the server must enforce.

For: Backend and platform engineers designing or operating GraphQL APIs

Guide scope and versions

GraphQL type-system and execution semantics with server implementation choices called out separately. DataLoader, query-cost limits, federation and subscriptions are implementation patterns, not guarantees supplied by the GraphQL specification alone.

Question 1 of 9

How do nullability and error propagation change the API contract?

GraphQL fields are nullable unless marked non-null. A resolver error on a nullable field can return null with an error while sibling data remains; an error at a non-null field propagates upward until it reaches a nullable boundary.

Suppose a dashboard returns an account and a private note. If the note is unavailable to this caller, a nullable note can be null while the account name remains useful. Marking the whole account path non-null can turn one field failure into null for a much larger parent object.

Nullability is a failure-containment decision as well as a type declaration. Choose it from the product meaning: use non-null only when the server can always provide the value or when failing the containing object is the intended contract.

JavaScript / GraphQL.js · Worked example
import assert from 'node:assert/strict';
import { GraphQLID, GraphQLNonNull, GraphQLObjectType, GraphQLSchema, GraphQLString, graphql } from 'graphql';

const accountType = new GraphQLObjectType({
  name: 'Account',
  fields: {
    id: { type: GraphQLID },
    name: { type: GraphQLString },
    privateNote: {
      type: GraphQLString,
      resolve: (account, _args, context) => context.viewerId === account.ownerId ? account.privateNote : null,
    },
    optionalBadge: { type: GraphQLString, resolve: () => { throw new Error('synthetic optional resolver failure'); } },
    requiredBadge: { type: new GraphQLNonNull(GraphQLString), resolve: () => { throw new Error('synthetic required resolver failure'); } },
  },
});
const schema = new GraphQLSchema({
  query: new GraphQLObjectType({
    name: 'Query',
    fields: { account: { type: accountType, resolve: () => ({ id: 'a1', name: 'Demo', ownerId: 'owner-1', privateNote: 'synthetic-private-note' }) } },
  }),
});
const contextValue = { viewerId: 'guest' };
const nullableResult = await graphql({ schema, source: '{ account { name privateNote optionalBadge } }', contextValue });
assert.equal(nullableResult.data.account.name, 'Demo');
assert.equal(nullableResult.data.account.privateNote, null);
assert.equal(nullableResult.data.account.optionalBadge, null);
assert.equal(nullableResult.errors[0].path.join('.'), 'account.optionalBadge');
assert.doesNotMatch(JSON.stringify(nullableResult), /synthetic-private-note/);

const nonNullResult = await graphql({ schema, source: '{ account { name requiredBadge } }', contextValue });
assert.equal(nonNullResult.data.account, null);
assert.deepEqual(Object.keys(nonNullResult.data), ['account']);
assert.equal(nonNullResult.errors[0].path.join('.'), 'account.requiredBadge');
console.log('nullable field error preserved sibling data; non-null error bubbled to account; guest private field stayed null');

This runs a real GraphQL.js schema with a named synthetic account and guest context. It asserts partial data and error paths for nullable and non-null resolver failures, plus that the guest cannot read the private note. It does not stand in for application-wide authorization policy.

Executed in GraphQL.js 16.11.0 on Node 24.21.0; nullable error paths, partial data and non-null bubbling asserted.

Follow-up: Is a nullable field the right way to represent forbidden data?

It can be, but the API must distinguish intentional omission from operational failure through documented errors or another explicit contract. Never rely on null alone when clients need to know whether to retry or request different access.

Read the source: GraphQL specification: Non-Null and error propagation · GraphQL: Execution

↑ Back to questions

Question 2 of 9

Which schema changes are safe for existing clients?

Adding an optional field or type is usually additive. Removing or renaming a field, changing an output to non-null, tightening accepted inputs, or changing semantics can break a client even when the schema still validates.

A client may still request a field that the server team considers obsolete. Deprecate it with a migration path, measure actual operation usage, support both representations during rollout, then remove it only after dependent clients have moved.

Schema-diff tools find structural changes, but they cannot determine every semantic break. Review null behavior, enum additions in exhaustive clients, authorization changes, ordering guarantees and changes in error meaning with representative consumers.

Follow-up: Can a field be removed as soon as it is deprecated?

No. Deprecation communicates intent; it does not prove consumers have migrated. Use operation telemetry and a versioned removal process with a rollback path.

Read the source: GraphQL specification: Type System Evolution · GraphQL: Schema evolution

↑ Back to questions

Question 3 of 9

Where should authorization happen in a nested graph?

Authorize every protected object and field at the server-side data boundary, using the authenticated principal and the requested parent object. Route-level checks alone do not cover every nested path, alias or reused resolver.

A user may have permission to read an account's public profile but not its billing contact. Enforce both the account membership rule and the billing-field rule; do not assume that reaching the account resolver grants access to every descendant.

Keep tenant filters in the database query where possible to avoid fetching another tenant's object and then filtering it in application code. Cache keys and DataLoader instances must be scoped so one principal cannot reuse another principal's authorized result.

Follow-up: Should every resolver duplicate the same authorization code?

No. Put policy in a shared domain/data-access boundary with explicit inputs, then make each resolver call that boundary. Reuse must preserve the actual resource and principal context rather than hide it in global state.

Read the source: Apollo Server: Authentication and authorization · OWASP: GraphQL Cheat Sheet

↑ Back to questions

Question 4 of 9

How do you identify and fix resolver N+1 work?

Count downstream calls for a representative query and measure the resolver path. A request-scoped DataLoader can batch sibling lookups and memoize within that operation, provided it preserves ordering, missing values and authorization scope.

A list query returns 50 projects and each project resolver loads its owner. A naive resolver issues one project query plus 50 owner queries. A loader can collect owner IDs and issue a bounded batch query, then map each result back to the original key order.

The loader should usually live for one operation so cached values do not cross requests or principals. Batching lowers round trips but can create a huge query if the list itself is unbounded, so pair it with pagination and a total cost budget.

Follow-up: Does DataLoader make any query cheap?

No. It consolidates repeated lookups. Measure row counts, selected columns, database plans and batch size; a batched full-table scan can still be expensive.

Read the source: Apollo Server: Data fetching and DataLoader · GraphQL: Execution

↑ Back to questions

Question 5 of 9

How do you make pagination stable while records change?

Use a deterministic ordering with a unique tie-breaker, encode the boundary in a cursor, and cap page size. Offset pagination can skip or repeat rows when earlier records are inserted or removed; cursor pagination still needs a defined consistency model.

Order events by created time and then event ID. A cursor containing only the timestamp is ambiguous when several events share that timestamp; the pair gives a stable next-page boundary. Validate the cursor rather than treating client-provided text as a database expression.

If a multi-page export needs a fixed snapshot, cursor ordering alone is not enough. Use a database snapshot, watermark or version boundary and explain what late-arriving records do. Returning hasNextPage should reflect the query's actual limit strategy.

Follow-up: Can a cursor be opaque and still be versioned?

Yes. Encode the ordering values and an optional version or snapshot token, validate and sign it when tampering matters, and retain compatibility while old cursors may still be in use.

Read the source: GraphQL Cursor Connections Specification · Apollo Server: Pagination

↑ Back to questions

Question 6 of 9

How should a client interpret data returned with GraphQL errors?

Separate request errors, which prevent execution, from field errors, which may accompany partial data. Clients should render valid independent fields, present an appropriate fallback for failed fields and avoid treating an error-bearing response as a complete success.

If a profile query returns a name while the billing service times out, preserve the name and show billing as unavailable with a retry option. Do not discard the entire object unless the failed field invalidates the whole view.

Include stable error codes and safe client-facing messages. Keep diagnostic traces in access-controlled logs with credentials, tokens and sensitive payloads omitted or redacted. Retry only operations and fields whose side effects are known; a mutation timeout may mean the write committed even though the response was lost.

Follow-up: Should every resolver error be exposed to the client?

No. Expose a stable, useful category and path when appropriate. Keep internal exceptions and diagnostic traces access-controlled, with query text, secrets and sensitive values omitted or redacted.

Read the source: GraphQL specification: Handling Field Errors · GraphQL: Execution

↑ Back to questions

Question 7 of 9

How do you prevent a valid query from exhausting the service?

Bound list sizes, depth or weighted field cost, aliases and execution time; add rate limits and concurrency controls tied to the authenticated caller. GraphQL validation confirms schema validity, not acceptable resource use.

A syntactically valid nested query can expand through several lists and request thousands of objects. Estimate cost from cardinality and resolver work rather than treating every selected field as equal. Reject over-budget requests before launching expensive downstream work.

Persisted operations can reduce the exposed query surface for controlled clients but do not replace authorization, runtime bounds or safe handling of public clients. Observe rejection rates and cost by operation without logging secrets or full sensitive variable payloads.

Follow-up: Should complexity be a fixed number for every client?

The bound may vary by trusted role or service tier, but keep a hard ceiling and ensure identity cannot be forged by a client. Include downstream fan-out and concurrency in the budget.

Read the source: OWASP: GraphQL Cheat Sheet · GraphQL: Security and demand control

↑ Back to questions

Question 8 of 9

How do you make a mutation safe to retry after a timeout?

Define an idempotency key and commit the domain change and its deduplication record atomically. For events emitted after the write, use an outbox or another durable handoff; a resolver return value cannot prove that external delivery happened exactly once.

A client submits createInvoice, the database commits, then the network drops before the response arrives. If the client retries with the same key, the server returns the original invoice result instead of creating a second invoice. Store a request hash too so the same key cannot be reused for different input.

A database transaction cannot atomically commit an unrelated message broker send. Write an outbox row in the same transaction, then publish it with an idempotent consumer or event ID. Define what clients see while the asynchronous side effect is pending.

Follow-up: Does a mutation field execute exactly once?

No. Clients, gateways and networks can retry. Design the operation for duplicate delivery and make the durable domain owner enforce idempotency.

Read the source: GraphQL specification: Mutations · AWS: Transactional outbox pattern

↑ Back to questions

Question 9 of 9

What additional failure modes appear with subscriptions?

A subscription is a long-lived operation with connection authentication, per-event authorization, backpressure, reconnect and delivery semantics. A successful initial handshake does not guarantee that a later event remains authorized or reaches the client.

A user subscribes to tenant events and then loses membership. Recheck the relevant authorization when delivering events or close the subscription promptly when membership changes. Avoid trusting a long-lived connection identity forever when permissions can be revoked.

Reconnects can duplicate or miss events unless the protocol and event source provide a cursor or replay contract. Bound queued messages, expire idle connections and observe dropped clients so one slow consumer cannot consume unbounded memory.

Follow-up: Do GraphQL subscriptions provide durable replay by themselves?

No. The GraphQL operation describes the result stream; the transport and event source must define persistence, ordering, resume cursors and duplicate handling.

Read the source: GraphQL specification: Subscription · Apollo Server: Subscriptions

↑ Back to questions

Salary context

Advertised salaries for these skills

These are Hacker News job posts that mention these technologies, not employee earnings or a measure of what a skill adds to pay. The amounts summarize annualized advertised minimums in approximate USD. Groups can overlap and differ in roles, locations and dates.

GraphQL posts

62 posts · 62 usable advertised salary amounts

2024-10-01 to 2026-11-02

$150,000

Median advertised minimum, approximate USD/year

Middle 50%: $100,548–$175,000

Explore GraphQL salaries → Browse matching job posts →
Currency and calculation basis

Approximate USD using ECB daily reference rates as of 2026-10-30. Original currencies and offer ranges remain on the source listings. These figures cover posts tagged GraphQL, rather than every job in the broader technology family.

↑ Back to questions

Keep exploring