GraphQL Schema Vocabulary
5 exercises — master GraphQL schema vocabulary: SDL, type system, non-null and list modifiers, built-in and custom scalars, enums, input types, and the three root operation types.
0 / 5 completed
GraphQL schema vocabulary quick reference
- SDL — Schema Definition Language; the text format for defining a GraphQL API contract
- ! (non-null) — guarantees the field will never return null
- Query — read-only, safe to cache; Mutation — writes data; Subscription — real-time push
- Scalar — leaf type with no sub-fields:
Int,Float,String,Boolean,ID - Custom scalar — domain-specific scalar (DateTime, Email, URL) with custom validation
- Enum — scalar restricted to a named set of values; prevents invalid string values
- Input type — argument object for mutations/queries; cannot be used as a return type
1 / 5
What is the Schema Definition Language (SDL), and what role does it play in a GraphQL API?
The SDL is the schema — every GraphQL API starts with it.
A minimal SDL example:
• Object types — the data structures (
• Fields — the properties of each type with their types
• The Query type — what clients can read (every root query field is an entry point)
• The Mutation type — what clients can write/change
• The Subscription type — what clients can subscribe to (real-time events)
Why SDL matters:
• It's the contract between your backend team and frontend teams
• Tools generate client code, documentation, and mocks directly from the SDL
• Schema-first development: write the SDL before writing resolvers
• Introspection: clients can query the API to discover its schema at runtime
Key vocabulary:
• SDL (Schema Definition Language) — the text format for defining a GraphQL schema
• Schema-first design — designing the API contract before implementation
• Introspection — the ability to query a GraphQL API to discover its own types and fields
A minimal SDL example:
type User {
id: ID!
name: String!
email: String!
posts: [Post!]!
}
type Post {
id: ID!
title: String!
author: User!
}
type Query {
user(id: ID!): User
posts: [Post!]!
}
type Mutation {
createPost(title: String!, authorId: ID!): Post!
}
What SDL defines:• Object types — the data structures (
User, Post)• Fields — the properties of each type with their types
• The Query type — what clients can read (every root query field is an entry point)
• The Mutation type — what clients can write/change
• The Subscription type — what clients can subscribe to (real-time events)
Why SDL matters:
• It's the contract between your backend team and frontend teams
• Tools generate client code, documentation, and mocks directly from the SDL
• Schema-first development: write the SDL before writing resolvers
• Introspection: clients can query the API to discover its schema at runtime
Key vocabulary:
• SDL (Schema Definition Language) — the text format for defining a GraphQL schema
• Schema-first design — designing the API contract before implementation
• Introspection — the ability to query a GraphQL API to discover its own types and fields