Queries and Mutations
Learn how to create queries and mutations using Deno.
We'll cover the following...
We'll cover the following...
Overview
Now that we have defined the schema, types, queries, and mutations, let’s dive deeper into these concepts. To keep everything simple, we’ll define the following queries:
getAllBooks()getAllAuthors()getBook(id: String)getAuthor(id: String)
We’ll also define the following mutations:
addBook(input: BookInput!)addAuthor(input: AuthorInput!)addReview(input: ReviewInput!)
Note: We’ll only add the entities for now and we won’t link them (that is, we won’t add an author and reviews to a book).
Queries
Now that we’ve listed our queries, let’s start defining them. First of all, we need some data, so let’s add the following example data:
Now let’s define our queries below:
We can use the code widget below to test our queries. Try using one of the queries we defined in a new ...