08 / 10

Describe interface type.

Difficulty: 5/10
schema design, type resolution, query performance

An Interface is an abstract type that includes a certain set of fields that a type must include to implement the interface.

  1. 1

    Interfaces are useful when you want to return an object or set of objects, but those might be of several different types.

  2. 2

    An interface specifies a set of fields that multiple object types can include

If an object type implements an interface, it must include all of that interface's fields:

Scenario Questions

0-2 years experience

  1. 1We need to add a new field to a Product type that already implements a CatalogItem interface. How would you update the schema and resolver so that the field is available through the interface?
  2. 2A client queries `search { ... on Book { title author } ... on Magazine { title issue } }`. If you forget to add `title` to the Magazine type, what error does the client see and why?

2-5 years experience

  1. 1During a sprint you notice that a query fetching `items { id name }` returns null for `name` on some objects that implement the `Node` interface. Walk me through how you'd debug the issue.
  2. 2Your team is debating whether to model `User` and `Admin` as separate types that both implement a `Person` interface or as a union. What factors would influence your decision?
  3. 3You need to deprecate a field on an interface without breaking existing clients. How would you approach this in the schema and in client code?

5-8 years experience

  1. 1Our GraphQL gateway aggregates services, each exposing its own version of a `SearchResult` interface. At scale we see increased latency in type resolution. How would you redesign the interface usage to reduce overhead?
  2. 2We want to add a new concrete type that implements an existing interface, but some older clients rely on the previous set of possible types for caching. What migration strategy would you propose?
  3. 3Explain how you would implement custom type‑resolution logic for an interface when the underlying data sources have heterogeneous identifiers.

8+ years experience

  1. 1Across multiple micro‑services we have overlapping domain models that each define their own `Entity` interface. As the platform scales, how would you create a unified interface strategy to avoid schema duplication and ensure consistent type resolution?
  2. 2Your organization plans to move from a monolithic GraphQL server to a federated architecture. What are the implications for interfaces, and how would you handle interface stitching and versioning across federated services?
  3. 3Discuss the long‑term maintenance trade‑offs of heavily using interfaces versus concrete types in a public API that must remain stable for third‑party developers.

Follow-up Questions

  • How does the server determine the concrete type for an interface field at runtime?
  • When would you prefer a union over an interface, and vice‑versa?
  • Can you add a new field to an existing interface without breaking current clients?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.