Skip to content

paige0701/django-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

practice graphql with graphene


Fetch Ingredients list

query {
  allIngredients {
    id
    name
    category {
        name
    }
  }
}
{
    "data": {
        "allIngredients": [
            {
                "id": "1",
                "name": "Eggs",
                "notes": "Good old eggs",
                "category": {
                    "name": "Dairy"
                }
            },
            {
                "id": "2",
                "name": "Milk",
                "notes": "Comes from a cow",
                "category": {
                    "name": "Dairy"
                }
            },
            {
                "id": "3",
                "name": "Beef",
                "notes": "Much like milk, this comes from a cow",
                "category": {
                    "name": "Meat"
                }
            },
            {
                "id": "4",
                "name": "Chicken",
                "notes": "Definitely doesn't come from a cow",
                "category": {
                    "name": "Meat"
                }
            }
        ]
    }
}

Fetch Category list

query {
  allCategories {
    id
    name
  }
}
{
    "data": {
        "allCategories": [
            {
                "id": "1",
                "name": "Dairy"
            },
            {
                "id": "2",
                "name": "Meat"
            }
        ]
    }
}

Fetch Category where ingredients category is Meat

query {
  categoryByName(name:"Meat") {
    id
    name
    ingredients {
        name
    }
  }
}
{
    "data": {
        "categoryByName": {
            "id": "2",
            "name": "Meat",
            "ingredients": [
                {
                    "name": "Beef"
                },
                {
                    "name": "Chicken"
                }
            ]
        }
    }
}