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 and detroitPizza. Pizza objects must have id, pizza, and toppings fields.

  • Since Greek and Detroit pizza have the same fields, create a GraphQL fragment called PizzaFragment.

  • Make sure both fields have pizza as an argument and variable.

  • Supply Greek pizza fields with Greek Pizza as an argument and Detroit pizza fields with Detroit Pizza as an argument.

Expected output

{
  "data": {
    "greekPizza": [
      {
        "id": 5,
        "pizza": "Greek Pizza"
      }
    ],
    "detroitPizza": [
      {
        "id": 7,
        "pizza": "Detroit Pizza"
      }
    ]
  }
}

Get hands-on with 1400+ tech skills courses.