Why do we need to wrap our resolver functions with 'Query'?

Why cant we just put the functions
tracksForHome and author as their own key without being nested by ‘Query’ or ‘Track’ ? As shown here

Hello! It’s possible (and common) for multiple fields in a GraphQL schema to have the same name, as shown here:

type Book {
  title: String
}

type Movie {
  title: String
}

In this example, it’s almost definitely true that Book.title and Movie.title need different resolvers. The resolver map format makes sure that every field in a GraphQL schema has a unique location for its specific resolver, even if that field shares a name with other fields.

2 Likes

Ah, so if we were not to follow the convention of including type headers, our resolvers would look like this?

title: () => {}
title: () => {}

So when we include Movie, and Book for headers. The resolver can distinguish which type it should get data from?

Book:
   title: () => {}

Movie:
   title: () => {}