I'm trying to understand the meaning and usage of the schema keyword on a GraphQL schema definition (SDL).
Let's take the following schema definition, for example:
# Enumeration type for a level of priority
enum Priority {
LOW
MEDIUM
HIGH
}
# Our main todo type
type Todo {
id: ID!
name: String!
description: String
priority: Priority!
}
type Query {
# Get one todo item
todo(id: ID!): Todo
# Get all todo items
allTodos: [Todo!]!
}
type Mutation {
addTodo(name: String!, priority: Priority = LOW): Todo!
removeTodo(id: ID!): Todo!
}
schema {
query: Query
mutation: Mutation
}
Can someone please explain to me the meaning of the schema keyword/block in the definition above, why do we anyway need it?
schema {
query: Query
mutation: Mutation
}