GraphQL
Schema and Types
Define types, enums, and scalars.
By EZ4Code Team
schematypeenum
Code
type Author {
id: ID!
name: String!
bio: String
books: [Book!]!
}
type Book {
id: ID!
title: String!
author: Author!
pages: Int
published: Boolean
}
enum Genre {
FICTION
NON_FICTION
SCIENCE
}
scalar DateTimeExplanation
A GraphQL schema declares object types with fields, where the ! suffix marks non-nullable fields and [Type!] denotes a non-null list of non-null items. Enums restrict a field to a fixed set of values, and custom scalars like DateTime delegate parsing to a resolver. Every schema needs a Query root type to be executable.