books that accepts two optional arguments: genre (String) and minRating (Float).title, author, genre, and rating.genre argument and having a rating greater than or equal to minRating are returned.books that accepts two optional arguments: genre (String) and minRating (Float).title, author, genre, and rating.genre argument and having a rating greater than or equal to minRating are returned.Book with fields title (String), author (String), genre (String), and rating (Float). Also, define a sample list of books called books with exactly these entries: { title: "The Hobbit", author: "J.R.R. Tolkien", genre: "Fantasy", rating: 4.8 }, { title: "1984", author: "George Orwell", genre: "Dystopian", rating: 4.6 }, { title: "Clean Code", author: "Robert C. Martin", genre: "Programming", rating: 4.7 }.Define the Book type with the four fields. Then create a constant array books with the exact book objects.
books that accepts two optional arguments: genre of type String and minRating of type Float. The query should return a list of Book objects.Define the Query type with a books field that takes genre and minRating as optional arguments and returns a list of Book.
books query that filters the books list. Use the arguments genre and minRating to return only books where the genre matches (if provided) and the rating is greater than or equal to minRating (if provided). If no arguments are given, return all books.Use books.filter() and check if args.genre is given, then match book.genre. Similarly, check args.minRating against book.rating. Return true only if both conditions pass.
typeDefs string with the Book and Query types, and export the resolvers object. Use the exact variable names typeDefs and resolvers.Define typeDefs as a template string with the schema, then export both typeDefs and resolvers.
What is the main purpose of filtering arguments in a GraphQL query?
Which of the following is the correct syntax to filter users by age greater than 25 in a GraphQL query?
{
users(age_gt: 25) {
id
name
}
}age_gt to filter values greater than 25.age_gt: 25 correctly; others use invalid or incorrect syntax.Given the query below, what will be the output if the database has users with ages 20, 30, and 40?
{
users(age_gte: 30) {
name
}
}Identify the error in the following GraphQL query that tries to filter products by price less than 100:
{
products(price_lt 100) {
id
name
}
}price_lt 100 is missing a colon ':' between the argument name and value.price_lt: 100.You want to query a list of books published after 2010 and with more than 300 pages. Which of the following GraphQL queries correctly applies both filters?
{
books(published_gt: 2010, pages_gt: 300) {
title
author
}
}Pass the test and this pattern moves unknown