Build the mental model
A GraphQL schema is a contract that declares every shape of data the API can return, using types. Built-in scalar types are `String`, `Int`, `Float`, `Boolean`, and `ID`; `!` marks a field non-null, and syntax like `[Type!]!` means a non-null list of non-null items. `Query` is a special root type that declares every readable entry point. This type language is called Schema Definition Language (SDL).
Connect it to a real scenario
We declare the Tutorial Platform's core `Tutorial` type with `id`, `title`, `summary`, `lessonCount`, and `isFeatured` fields. Marking `id` as `ID!` (non-null) enforces at the schema level that every tutorial must have an id. Notice the difference inside `Query` between `tutorial(id: ID!): Tutorial` (a single, nullable item) and `tutorials: [Tutorial!]!` (a non-null list).
Try the working example
type Tutorial {
id: ID!
title: String!
summary: String
lessonCount: Int!
isFeatured: Boolean!
}
type Query {
tutorial(id: ID!): Tutorial
tutorials: [Tutorial!]!
}You can read and write a simple schema using types, scalars, and non-null/list syntax.5-minute try-it
Write an `Author` type with `id`, `name`, and a nullable `bio`, plus a `tutorials` list field, and a `Query` extension with `author(id: ID!): Author`.
One important caution
Marking a field non-null (`!`) and then having the resolver return `null` causes a GraphQL execution error. If a field can legitimately be missing, leave it nullable.
GraphQL — Schemas and Types — GraphQL