...

/

Root Fields and Resolvers

Root Fields and Resolvers

Learn how root fields and resolvers work in GraphQL.

In this lesson, we’ll learn how a GraphQL query is executed by a GraphQL server that returns a response that reflects the structure of the invoked GraphQL query.

The sample query below is the same as the type system used throughout the lesson.

Press + to interact
type Pizza {
id: Int!
pizza: String!
stock: Int!
toppings: [Topping!]!
}
type Topping {
id: Int!
topping: String!
}
type Query {
pizzas: [Pizza]
}

Let’s use one of our previous queries as an example.

Press + to interact
query{
pizzas {
__typename
... on Pizza {
id
toppings {
id
topping
}
pizza
}
}
}

We can ...