This article is about the schema (type) definition of GraphQL.
The implementation graphql/type module is the engine for defining GraphQL types and schema.
The below type is a shorthand notation. The API is more expressive and allows types and fields to be documented. See the getting started schema starWarsSchema.js
enum Episode { NEWHOPE, EMPIRE, JEDI }
interface Character {
id: String! // ! means not null
name: String
friends: [Character]
appearsIn: [Episode]
}
type Human implements Character {
id: String
name: String
friends: [Character]
appearsIn: [Episode]
homePlanet: String
}
type Droid implements Character {
id: String
name: String
friends: [Character]
appearsIn: [Episode]
primaryFunction: String
}
type Query {
hero(episode: Episode): Character
human(id: String!): Human
droid(id: String!): Droid
}