Q16: How do Interfaces work in GraphQL SDL?

Difficulty:IntermediateTopic:Schema Design

An interface is an abstract type that defines a set of fields that any implementers must include. Object types can implement one or multiple interfaces.

GraphQL Interface Syntax
interface Character {
  id: ID!
  name: String!
}

type Hero implements Character {
  id: ID!
  name: String!
  superpower: String!
}
💡 Type Hero implements Character and must declare id and name fields.
Key Takeaways
  • Interfaces establish abstract guarantees across diverse GraphQL types.
Knowledge Check

Must an object type implement every field defined in its interface?