Explain Interfaces and Unions in GraphQL.

Updated Apr 28, 2026

Short answer

Both are abstract types. An Interface defines a shared set of fields that implementing types must include. A Union is a logical OR of multiple types without shared fields.

Deep explanation

Interfaces are used when types share common traits (e.g., Character interface with a name field, implemented by Human and Droid). Unions are used when returning completely different object types (e.g., SearchResult can be a User OR an Article). Inline fragments are required to query specific fields.

Real-world example

Returning a feed of diverse activities (ImagePost, TextPost, VideoPost) using an Interface, allowing the client to render them differently.

Common mistakes

  • Trying to query non-shared fields on an Interface without using an inline fragment `... on SpecificType`.

Follow-up questions

  • What is __typename?

More GraphQL interview questions

View all →