Challenge: Tricky Pizzas Query
The challenge below tests your knowledge of complex GraphQL queries.
We'll cover the following
Problem statement
-
Write a GraphQL query to get two types of pizzas (Greek and Detroit) from the
pizzas
field. -
Query the
pizzas
fields with the following aliases:greekPizza
anddetroitPizza
. Pizza objects must haveid
,pizza
, andtoppings
fields. -
Since
Greek
andDetroit
pizza have the same fields, create a GraphQL fragment calledPizzaFragment
. -
Make sure both fields have
pizza
as an argument and variable. -
Supply
Greek
pizza fields withGreek Pizza
as an argument andDetroit
pizza fields withDetroit Pizza
as an argument.
Expected output
{
"data": {
"greekPizza": [
{
"id": 5,
"pizza": "Greek Pizza"
}
],
"detroitPizza": [
{
"id": 7,
"pizza": "Detroit Pizza"
}
]
}
}
Get hands-on with 1200+ tech skills courses.