Updating our Schema
Explore how to update your MongoDB schema for Book, Author, and Review collections while managing relationships via authorId and reviewIds. Learn to define detailed GraphQL queries and mutations, implement resolvers with TypeScript using MongoDB driver methods, and test your GraphQL endpoint integrated with MongoDB in a Deno application.
We'll cover the following...
We'll cover the following...
Schema types and inputs
Our MongoDB database has three entities: Book, Author, and Review. Let’s consider the following schema:
MongoDB schema
To access our database, we will need to define our schema as follows (they can be different from the GrapghQL ones):
In the schema definition given above, we try to use different approaches when handling the relationship between entities. It’s important to note the following:
authorIdis a field in the book schema used to reference the author of the book.reviewIdsis an array of review