Introduction
Good schema design makes it easy and fast to get the data you want. Bad design can make using the database confusing and slow.
Jump into concepts and practice - no test required
Good schema design makes it easy and fast to get the data you want. Bad design can make using the database confusing and slow.
type TypeName {
fieldName: FieldType
anotherField: AnotherType
}type User {
id: ID!
name: String
email: String
}type Post {
id: ID!
title: String
author: User
}This schema lets you ask for a user by ID and get their name and posts. Good design groups related data and shows connections clearly.
type Query {
user(id: ID!): User
}
type User {
id: ID!
name: String
posts: [Post]
}
type Post {
id: ID!
title: String
content: String
}Clear schema helps frontend developers know exactly what data they can ask for.
Good design avoids repeating data and keeps things organized.
Think about how people will use the data when designing your schema.
Good schema design makes data easy to find and use.
It helps avoid confusion and slow queries.
Design with users and developers in mind for best results.
id and name?type User { id: Int name: String }.type Query { user(id: ID!): User }
type User { id: ID! name: String }{ user(id: "1") { name } } return if the user with id 1 has name "Alice"?type User { id: ID! name: String }{ user { id name } }?