Skip to content

A GraphQL API built on Neo4j for managing and exploring recipes and their relationships. This API supports features like CRUD operations, ingredient-based recipe search, and graph-based relationship visualization, offering an intuitive way to handle recipe data.

Notifications You must be signed in to change notification settings

akramex-dz/recipe_book_api

Repository files navigation

Recipe Book API Documentation

This document provides details about the GraphQL API for the Recipe Book application. The API is hosted at https://recipebookapi.vercel.app/. The Client-app is hosted at https://recipes-book-graphql.vercel.app/.

API Overview

The API supports the following functionality:

  • User authentication (registration and login)
  • Fetching user details
  • CRUD operations for recipes
  • Fetching ingredients and categories

Quick Start Example

Register a User

POST https://recipebookapi.vercel.app/

Request Body:

{
  "query": "mutation registerUser($username: String!, $email: String!, $password: String!) { registerUser(username: $username, email: $email, password: $password) { token user { id username email } } }",
  "variables": {
    "username": "",
    "email": "",
    "password": ""
  }
}

Response:

{
  "data": {
    "registerUser": {
      "user": {
        "id": "",
        "username": "",
        "email": ""
      }
    }
  }
}

Schema and Resolvers Overview

Queries

Get User Information

Retrieve details about the authenticated user.

  • Query:
    query {
      getUserInformation {
        id
        username
        email
      }
    }
  • Headers: Authorization: Bearer <JWT_TOKEN>

Get All Recipes

Retrieve all recipes, including their ingredients and related details.

  • Query:
    query {
      getRecipes {
        id
        title
        description
        difficulty
        time
        ingredients {
          id
          name
        }
        category {
          id
          name
        }
        createdBy {
          id
          username
        }
      }
    }

Get Recipe by ID

Retrieve a specific recipe by its ID.

  • Query:
    query getRecipeById($id: ID!) {
      getRecipeById(id: $id) {
        id
        title
        description
        difficulty
        time
        ingredients {
          id
          name
        }
        category {
          id
          name
        }
        createdBy {
          id
          username
        }
      }
    }
  • Variables:
    {
      "id": "RECIPE_ID"
    }

Get All Ingredients

Retrieve all ingredients and their associated recipes.

  • Query:
    query {
      getIngredients {
        id
        name
        recipes {
          id
          title
        }
      }
    }

Get Ingredient by ID

Retrieve a specific ingredient by its ID.

  • Query:
    query getIngredientById($id: ID!) {
      getIngredientById(id: $id) {
        id
        name
      }
    }
  • Variables:
    {
      "id": "INGREDIENT_ID"
    }

Mutations

Register a User

Register a new user.

  • Mutation:
    mutation registerUser($username: String!, $email: String!, $password: String!) {
      registerUser(username: $username, email: $email, password: $password) {
        token
        user {
          id
          username
          email
        }
      }
    }
  • Variables:
    {
      "username": "",
      "email": "@example.com",
      "password": ""
    }

Login User

Authenticate a user and retrieve a token.

  • Mutation:
    mutation loginUser($email: String!, $password: String!) {
      loginUser(email: $email, password: $password) {
        token
        user {
          id
          username
          email
        }
      }
    }
  • Variables:
    {
      "email": "",
      "password": ""
    }

Create a Recipe

Add a new recipe.

  • Mutation:
    mutation createRecipe(
      $title: String!,
      $description: String!,
      $difficulty: String!,
      $time: Int!,
      $ingredients: [String!]!,
      $category: String!,
      $createdByUserId: ID!
    ) {
      createRecipe(
        title: $title,
        description: $description,
        difficulty: $difficulty,
        time: $time,
        ingredients: $ingredients,
        category: $category,
        createdByUserId: $createdByUserId
      ) {
        id
        title
        description
        difficulty
        time
      }
    }
  • Variables:
    {
      "title": "Pasta Carbonara",
      "description": "Classic Italian dish.",
      "difficulty": "Medium",
      "time": 30,
      "ingredients": ["Pasta", "Eggs", "Cheese", "Bacon"],
      "category": "Italian",
      "createdByUserId": "USER_ID"
    }

Authentication

Most queries and mutations require authentication. Use the Authorization header to provide your token:

Authorization: Bearer <JWT_TOKEN>

About

A GraphQL API built on Neo4j for managing and exploring recipes and their relationships. This API supports features like CRUD operations, ingredient-based recipe search, and graph-based relationship visualization, offering an intuitive way to handle recipe data.

Topics

Resources

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •