graphqlinterface

Is it a must for an implementation to explicity mention all interface fields or can it skip them as understood?


Lets say an interface like below exists?

interface Node {
  id: ID!
  something1: string,
  something2: number
}

Should it be implemented as below?

    type User implements Node {
       id: ID!
       something1: string,
       something2: number,
       something3: string
    } 

or can it be implemented as below and understood that the interface fields are included

type User implements Node {
    something3: string
} 

Or is there a rule that only non-nullable fields have to be explicitly mentioned like below

type User implements Node {
    id: ID!
    something3: string
}

Solution

  • docs

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

    Therefore your first case is the correct one.