Welcome to the Recipe Graphql API! This API allows you to retrieve, edit, update, delete using GraphQL Queries.
here is the playground screenshot
- Node.js
- Express.js
- GraphQL
- MongoDB
- Apollo Server
- Mongoose
- Typescript
To run this project locally, you will need to have the following installed on your machine:
- Node.js
- MongoDB
- Yarn
To install this project, follow these steps:
- Clone the repository
- Run
yarn install
to install the dependencies - Create a
.env
file in the root directory and add the following variables:
MONGO_URI= "mongodb://127.0.0.1:27017/recipe-gql-api" || "your-mongo-atlas-uri"
- Run
yarn dev
to start the server - Navigate to
http://localhost:5000/
to view the GraphQL Playground - You can now send queries to the API
To use this API, you can send a gql query and mutation to the following endpoint:
https://localhost:5000/
query Query {
getRecipes {
ID,
category
createdAt
description
name
originated
updatedAt
}
}
This will return a JSON object with information about a recipe
The response from the API will be in the following format:
{
"data": {
"getRecipes": [
{
"ID": "60c0a0a0e1b3a1a0e8a0a0a0",
"category": "test",
"createdAt": "1683480182148",
"description": "this is awesome Recipe",
"name": "Test Recipe 2",
"originated": "test origin",
"updatedAt": "1683480182148"
},
{
"ID": "60c0a0a0e1b3a1a0e8a0a0a0",
"category": "test",
"createdAt": "1683479768142",
"description": "Test Description updated",
"name": "Test Name",
"originated": "test origin updated",
"updatedAt": "1683480043516"
}
]
}
}
query Query($ID: String!) {
recipe(ID: $ID) {
ID,
category
createdAt
description
name
originated
updatedAt
}
}
{
"ID": "60c0a0a0e1b3a1a0e8a0a0a0"
}
{
"data": {
"recipe": {
"ID": "60c0a0a0e1b3a1a0e8a0a0a0",
"category": "test",
"createdAt": "1683480182148",
"description": "this is awesome Recipe",
"name": "Test Recipe 2",
"originated": "test origin",
"updatedAt": "1683480182148"
}
}
}
mutation Mutation($recipe: RecipeInput) {
createRecipe(recipe: $recipe) {
ID,
category,
createdAt,
description,
name,
originated,
updatedAt,
}
}
{
"recipe": {
"category": "test",
"description": "this is awesome Recipe",
"name": "Test Recipe 2",
"originated": "test origin"
}
}
{
"data": {
"createRecipe": {
"ID": "60c0a0a0e1b3a1a0e8a0a0a0",
"category": "test",
"createdAt": "1683480182148",
"description": "this is awesome Recipe",
"name": "Test Recipe 2",
"originated": "test origin",
"updatedAt": "1683480182148"
}
}
}
mutation Mutation($ID: String!, $recipe: RecipeInput) {
updateRecipe(ID: $ID, recipe: $recipe) {
ID,
category,
createdAt,
description,
name,
originated,
updatedAt,
}
}
{
"ID": "60c0a0a0e1b3a1a0e8a0a0a0",
"recipe": {
"category": "test",
"description": "this is awesome Recipe",
"name": "Test Recipe 2",
"originated": "test origin"
}
}
{
"data": {
"updateRecipe": {
"ID": "60c0a0a0e1b3a1a0e8a0a0a0",
"category": "test",
"createdAt": "1683480182148",
"description": "this is awesome Recipe",
"name": "Test Recipe 2",
"originated": "test origin",
"updatedAt": "1683480182148"
}
}
}
mutation Mutation($id: String!) {
deleteRecipe(ID: $id)
}
{
"id": "60c0a0a0e1b3a1a0e8a0a0a0"
}
{
"data": {
"deleteRecipe": true
}
}
If you would like to contribute to this project, feel free to fork the repository and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.