📖 Scenario: You work as a data analyst for a customer support team. They want to classify error messages from their system logs into categories to understand common problems.
🎯 Goal: Build a simple GraphQL query that returns error messages and their classification categories from a predefined dataset.
📋 What You'll Learn
Create a list of error messages with their types
Add a variable to filter errors by a specific type
Write a GraphQL query to select errors matching the filter
Display the filtered error messages and their categories
💡 Why This Matters
🌍 Real World
Classifying error messages helps support teams quickly identify and fix common problems in software systems.
💼 Career
Understanding how to filter and query data with GraphQL is useful for backend developers and data analysts working with APIs.
Progress0 / 4 steps
1
Create the error messages dataset
Create a list called errors with these exact entries: { id: 1, message: "Timeout error", category: "Network" }, { id: 2, message: "Null pointer exception", category: "Code" }, { id: 3, message: "Disk full", category: "Storage" }, { id: 4, message: "Timeout error", category: "Network" }.
GraphQL
Hint
Use an array of objects with id, message, and category keys.
2
Add a filter variable for category
Create a variable called filterCategory and set it to the string "Network".
GraphQL
Hint
Use a constant string variable to hold the category filter.
3
Write a GraphQL query to filter errors by category
Write a GraphQL query called getErrorsByCategory that takes a category argument of type String! and returns id, message, and category fields for errors matching the argument.
GraphQL
Hint
Define a GraphQL query type with a category argument and filter the errors array in the resolver.
4
Display the filtered error messages and categories
Write a console.log statement that prints the result of calling resolvers.Query.getErrorsByCategory with { category: filterCategory } as argument.
GraphQL
Hint
Call the resolver function with null as first argument and an object with category: filterCategory as second argument, then print the result.
Practice
(1/5)
1. What is the main purpose of error classification in data science models?
easy
A. To group model mistakes into clear categories for better understanding
B. To increase the speed of the model's predictions
C. To reduce the size of the dataset
D. To improve the model's user interface
Solution
Step 1: Understand error classification
Error classification means sorting mistakes into groups to see patterns.
Step 2: Identify the goal of grouping errors
Grouping helps find where the model works well or needs improvement.
Final Answer:
To group model mistakes into clear categories for better understanding -> Option A
Quick Check:
Error classification = Group mistakes [OK]
Hint: Error classification groups mistakes to spot issues fast [OK]
Common Mistakes:
Thinking error classification speeds up predictions
Confusing error classification with data size reduction
Believing it improves user interface
2. Which GraphQL query structure correctly requests error counts grouped by error type?
easy
A. query { errorCountList { errorType, total } }
B. query { errors { count type } }
C. query { errorCounts(type, count) }
D. query { errorCounts { type count } }
Solution
Step 1: Identify correct GraphQL syntax
GraphQL queries use curly braces with fields inside, like { errorCounts { type count } }.
Step 2: Check field names and order
query { errorCounts { type count } } uses correct field names and structure matching typical GraphQL style.